C program to find ncr code: #include <stdio.h> int fact(int); void main() { int n,r,ncr; printf("Enter a number n:"); scanf("%d",&n); printf("Enter a number r:"); scanf("%d",&r); ncr=fact(n)/(fact(r)*fact(n-r)); printf("Value of %dC%d = %d\n",n,r,ncr); } int fact(int n) { int i,f=1; for(i=1;i<=n;i++) { f=f*i; } return f; } Explanation: In this program we are using "function" concept. To find ncr we first declare the variables We get the output from the user and store them. ncr formula is " ncr=fact(n)/(fact(r)*fact(n-r))" To print the result we are using printf stat...
Comments
Post a Comment