programming-examples/c/Recursion/C Program to Find the NCr value by using recursive function.c
2019-11-15 12:59:38 +01:00

20 lines
360 B
C

#include<stdio.h>
int main()
{
int n,r,ncr;
printf("Enter any two numbers->");
scanf("%d %d",&n,&r);
ncr=fact(n)/(fact(r)*fact(n-r));
printf("The NCR factor of %d and %d is %d",n,r,ncr);
return 0;
}
int fact(int n)
{
int i=1;
while(n!=0)
{
i=i*n;
n--;
}
return i;
}