0

Hii Everyone... I used to be an active member of this community... but because of studies i wasnt able to keep in touch with you guys..

Am an amateur programmer,and i need your help... I have written a programme to find nCr[n combination r] nCr=n!/(n-r)! I want the compiler to show the value of NC2 for all values of n<=10 ..So I added a for loop with variable i... but the loop inst working properly...I need your help...here is the code

```
/* A program to find nCr[ n!/r!(n-r)! ]
*/
#include<iostream.h>
#include<conio.h>
long factorial(int);
int main()
{
clrscr();
long i,n,r,f,f1,f2,fact,j;
cout<<"Enter the values of n and r :\t ";
cin>>n>>r;
for(i=1;i<n;i++)
{
f=factorial(i);
f1=factorial(r);
f2=factorial(i-r);
fact=f/(f1*f2);
cout<<"Result"<<fact<<'\n';
long factorial(int i)
long f;
if(i==1)
f=1;
else
f=i*factorial(i-1);
return(f);
}
getch();
}
```