Wisdom Materials
Home
About Us
Our Clients
Careers
Services
Education
Jobs
News
Business
Health
Astrology
Entertainment
RealEstate
Devotion
Contact Us
C Programs
/ ncr C Program
ncr = n! / r! (n-r)!
Program
Copy text
#include
int ncr(int n,int r); void main() { int n,r,ncrvalue; printf("Enter n and r values:\n"); scanf("%d %d",&n,&r); ncrvalue=ncr(n,r); printf("ncr value=%d\n",ncrvalue); } int ncr(int n,int r) { int ncrvalue,res; if(r==0) { ncrvalue=1; return ncrvalue; } else if(n==r) { ncrvalue=1; return ncrvalue; } else res=ncr(n-1,r-1)+ncr(n-1,r); return res; }
Input
Enter n and r values:5 2
Output
ncr value=10
Home
Back