Thursday, July 25, 2013

Program to find n!/(r!(n-r)!)

#include<iostream.h>
#include<conio.h>
int fact(int);
void main()
{
clrscr();
int n,r,f,f1,f2,ft;
cout<<"Enter the value of n and r : ";
cin>>n>>r;
f=fact(n);
f1=fact(r);
f2=fact(n-r);
ft=f/(f1*f2);
cout<<"result : "<<ft;
getch();
}
int fact(int n)
{
int x;
if(n==1)
x=1;
else
x=n*fact(n-1);
return(x);
}

To know about function click here

No comments:

Post a Comment