#include<stdio.h>
int fact(int x);
int main()
{
int n,r,ncr;
printf("Enter N and R values: ");
scanf("%d %d",&n,&r);
ncr=fact(n)/(fact(r)*fact(n-r));
printf("The NCR of %d and %d is %d",n,r,ncr);
return 0;
}
// x is a formal parameter or dummy parameter
// Calculate using n!/(n-r)!*r!
int fact(int x)
{
int i=1;
while(x!=0)
{
i=i*x;
x--;
}
return i;
}
OUTPUT:
Enter N and R values: 5 2 The NCR of 5 and 2 is 10