#include<stdio.h>
long int fact(int p);
main()
{
int n,r;
float ncr;
printf("enter n and r\n");
scanf("%d%d",&n,&r);
ncr=(float)(fact(n))/(fact(r)*fact(n-r));
printf("ncr=%f",ncr);
}
long int fact(int p)
{
long int f=1;
int i;
for(i=1; i<=p; i++)
{
f=f*i;
}
return f;
}
Note: Need to be arranged in compiler after copied
OutPut:
enter n and r
5
3
ncr=10.000000