1: #include<stdio.h>
2: #include<conio.h>
3:
4: long getfact(int n);
5: void main()
6: {
7: int n,r;
8: int ncr;
9: printf("Enter n and r: ");
10: scanf("%d%d",&n,&r);
11: ncr=getfact(n)/((getfact(r))*getfact(n-r));
12: printf("Combination of %d items taken %d at a time: %d",n,r,ncr);
13: getch();
14: }
15: long getfact(int n)
16: {
17: int i;
18: long fact=1;
19: for(i=1;i<=n;i++)
20: fact=fact*i;
21: return(fact);
22: }
No comments:
Post a Comment