programming-examples/c/Functions/C program to Calculate the Value of nPr.c
2019-11-15 12:59:38 +01:00

21 lines
390 B
C

/*
* C program to Calculate the Value of nPr
*/
#include <stdio.h>
void main(void)
{
printf("%d\n", fact(8));
int n, r;
printf("Enter value for n and r\n");
scanf("%d%d", &n, &r);
int npr = fact(n) / fact(n - r);
printf("\n Permutation values is = %d", npr);
}
int fact(int x)
{
if (x <= 1)
return 1;
return x * fact(x - 1);
}