Examples of C part 48 calculate combination value nCr

Program:

#include<stdio.h>
int factorial(int);
main()
{
int n,r;
float nCr;
printf("Enter value of n in nCr\n");
scanf("%d",&n);
printf("Enter value of r in nCr\n");
scanf("%d",&r);
if(n>=r&&n>=0&&r>=0)
{
   nCr=(float)factorial(n)/(factorial(r)*factorial(n-r));
   printf("Value of %dC%d=%f\n",n,r,nCr);
}
else
{
 printf("Invalid Entry\n");
}

}

int factorial(int num)
{
 int i,fact=1;
 for(i=1;i<=num;i++)
 {
  fact=fact*i;
 }

 return(fact);
}
Output:
Enter value of n in nCr
9
Enter value of r in nCr
6
Value of 9C6=84.000000
Explanation:
Formula for permutation us nCr=n!/r!(n-r)! under condition of  n>=r,n>=0,r>=0