/* Calculate Permutation and Combination (nCr and nPr)
Using Function */
#include<stdio.h>
#include<conio.h>
void main()
{
int n,c,r,ncr,npr;
long int fact( int ); /* function Prototype */
clrscr();
printf(“Enter the Value of n and r, n must be n>r :\n”);
scanf(“%d%d”,&n,&r);
ncr= fact(n)/fact(n-r);
npr= fact(n)/(n*fact(n-r));
printf(“NCR = %d\n”,ncr);
printf(“NPR = %d\n”,npr);
getch();
}
long int fact( int x)
{
long int f=1;
int i;
for(i=1;i<=x;i++)
f=f*i;
return(f);
}
Latest posts by Mohit Arora (see all)
- MongoDB Operators Tutorial – What are Different Operators Available? - October 5, 2019
- MongoDB Projection Tutorial : Return Specific Fields From Query - March 9, 2019
- MongoDB Index Tutorial – Create Index & MongoDB Index Types - July 6, 2018