Write a program (WAP) that will find n C r where n >= r; n and r are integers.
Answers
Answered by
0
Answer:
bha
Explanation:
Answered by
0
Answer:
#include<stdio.h>
int main()
{
int N, r, i, RESULT;
int fact1, result1 = 1, fact2, result2 = 1, fact3, result3 = 1;
scanf("%d", &N);
scanf("%d", &r);
for(i = N; i >= 1; i--)
{
fact1 = i;
result1 = (fact1*result1);
}
printf("N = %d\n", result1);
for(i = r; i >= 1; i--)
{
fact2 = i;
result2 = (fact2*result2);
}
printf("R = %d\n", result2);
for(i = (N-r); i >= 1; i--)
{
fact3 = i;
result3 = (fact3*result3);
}
printf("N-r = %d\n", result3);
RESULT = (result1/(result2*result3));
printf("nCr = %d", RESULT);
return 0;
}
Explanation:
Similar questions