#include<stdio.h>//header file
#include<conio.h>//header file
void main() //starting of the main() function
{
int n,r,p=1,v=1,i,f; //declaration of the variables
float d,c=1;
clrscr();
printf("program that calculates nCr");
printf("\n\n\n\t\t------------INPUT-------------");
printf("\n\nenter the value of n and r for nCr");//taking input from the user
scanf("%d%d",&n,&r);
if(n>=r)
{
for(i=2;i<=n;i++)
{
c=c*i;
}
for(i=2;i<=r;i++)
{
p=p*i;
}
f=n-r;
for(i=2;i<=f;i++)
{
v=v*i;
}
d=c/(p*v);
if(n==0)
d=0;
printf("\n\n\n\t\t------------OUTPUT------------");
printf("\n\nthe value of %dC%d is =%f",n,r,d);//printing output
}
else
printf("\n\nthe value of n is lesser than value of r -wrong choice");
getch();
}