Created
May 8, 2016 08:28
-
-
Save complxalgorithm/10440e06a25478207fae4e5b107d7623 to your computer and use it in GitHub Desktop.
C program to calculate nCr.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* C program to Calculate the value of nCr | |
*/ | |
#include <stdio.h> | |
int fact(int z); | |
void main() | |
{ | |
int n, r, ncr; | |
printf("\n Enter the value for N and R \n"); | |
scanf("%d%d", &n, &r); | |
ncr = fact(n) / (fact(r) * fact(n - r)); | |
printf("\n The value of ncr is: %d", ncr); | |
} | |
int fact(int z) | |
{ | |
int f = 1, i; | |
if (z == 0) | |
{ | |
return(f); | |
} | |
else | |
{ | |
for (i = 1; i <= z; i++) | |
{ | |
f = f * i; | |
} | |
} | |
return(f); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment