C Program to Find NCR Of A Given Number Program

How to write a C Program to Find NCR Of A Given Number in C Programming Language ?

Solution For C Program :

/*C Program to Find NCR Of A Given Number Program*/

#include <stdio.h>
void main()
{
int n, r;
float NCR(int,int);
int Factorial(int n);
printf("\nEnter value for n and r : ");
scanf("%d%d", &n, &r);
printf("\nThe NCR = %0.2f", NCR(n, r));
}
float NCR(int n, int r)
{
int factorial(int);
return((float)factorial(n) / ((float)factorial(n - r) * (float)factorial(r)));
}
int factorial(int n)
{
int k, fact;
for(k = 1, fact = 1; k <= n; k++)
fact = fact * k;
return(fact);
}


You may also learn these C Program/Code :

C Program To Swap Two Numbers Without Using Third Variable


Learn More :