#include<stdio.h>
main()
{
long fact(int);
int n,r,i;
long npr,ncr;
clrscr();
printf("\nEnter the value for N and R\n");
scanf("%d%d",&n,&r);
if(r<=n)
{
npr=fact(n)/fact(n-r);
ncr=npr/fact(r);
printf("\n%dP%d= %ld",n,r,npr);
printf("\n%dC%d= %ld",n,r,ncr);
}
else
{
printf("\nWrong Input (R<N)\n");
}
getch();
}
long fact(int n)
{
if(n!=0)
return(n*fact(n-1));
else
return (1);
}
Comments
Post a Comment