Saturday, August 20, 2011

Program to compute nCr formula.

//Program to compute nCr formula.
#include<stdio.h>
#include<conio.h>
long int fact(int);
void main()
{
 int n,r;
 long int f,res;
 clrscr();
 printf("Enter the value of n");
 scanf("%d",&n);
 printf("Enter the value of r");
 scanf("%d",&r);
 res=fact(n)/(fact(r)*fact(n-r));
 printf("The result of nCr is %ld",res);
 getch();
}
long int fact(int x)
{
if(x==0||x==1)
return 1;
else
return (x*fact(x-1));
}

Previous Next Home
0 Comments
Comments

Leave a Comment

:)) ;)) ;;) :D ;) :p :(( :) :( :X =(( :-o :-/ :-* :| 8-} :)] ~x( :-t b-( :-L x( =))

Twitter Delicious Facebook Favorites More