Write A Program for calculating NCR using Functions
# include<stdio.h> #include<conio.h> void main ( ) { int n, r, ncr, a, b, c; clrscr( ) ; int fact ( int); pri...
https://www.computersprofessor.com/2016/06/write-program-for-calculating-ncr-using.html
# include<stdio.h>
#include<conio.h>
void main ( )
{
int n, r, ncr, a, b, c;
clrscr( ) ;
int fact ( int);
printf (“enter n, r values”);
scanf ("%d%d”, & n, & r);
a = fact (n);
b = fact (r);
c= fact (n-r);
ncr = a/b*c;
printf (“\n ncr value is %d”, ncr );
getch ( );
}
int fact ( int x)
{
int i, y=1;
for ( i = 1; i < = x; i ++)
y = y * i;
return ( y);
}