C Program to find Permutations nPr
Program
#include <stdio.h>
int fact(int n) {
int i = 1;
while (n != 0) {
i = i * n;
n--;
}
return i;
}
void main() {
int n, r, npr;
printf("Enter value of n:\t");
scanf("%d", &n);
printf("Enter value of r:\t");
scanf("%d", &r);
npr = fact(n) / fact(n - r);
printf("Permutation:\t%d\n", npr);
}
Output
Enter value of n: 6
Enter value of r: 2
Permutation: 30