#include<stdio.h>
#include<conio.h>
int bin(int,int);
int main()
{
int n,r,result;
printf("Enter value N: ");
scanf("%d",&n);
printf("Enter value R: ");
scanf("%d",&r);
if(n<0||r<0||n<r)
printf("Invalid input....");
else
{
result=bin(n,r);
printf("C(%d,%d)= %d",n,r,result);
}
getch();
return 0;
}
int bin(int n,int r)
{
if(r==0)
return 1;
else
{
if(n<r)
return 0;
else
return(bin(n-1,r)+bin(n-1,r-1));
}
}
#include<conio.h>
int bin(int,int);
int main()
{
int n,r,result;
printf("Enter value N: ");
scanf("%d",&n);
printf("Enter value R: ");
scanf("%d",&r);
if(n<0||r<0||n<r)
printf("Invalid input....");
else
{
result=bin(n,r);
printf("C(%d,%d)= %d",n,r,result);
}
getch();
return 0;
}
int bin(int n,int r)
{
if(r==0)
return 1;
else
{
if(n<r)
return 0;
else
return(bin(n-1,r)+bin(n-1,r-1));
}
}
No comments:
Post a Comment
Convey your thoughts to authors.