## C Program To Calculate nPr Value

Learn How To Calculate nPr in C Programming Language. This C Program makes use of the **Factorial Function in C Programming **to find the Value of nPr. nPr is also commonly written as **P(n/r)**.

This C Code to Find Value of nPr finds the total Number of different Permutations of **n** Distinct Points taken **r** at a time. An important part of finding combination in C Programming is calculation of the Factorial of a Number.

#### Mathematical Formula To Find Permutation P(n, r)

#### C Program To Calculate nPr using Function

#include<stdio.h> int Factorial(int x) { int factorial = 1, count; for(count = x; count > 1; count--) { factorial = factorial * count; } return factorial; } int main() { int n, r; float result; printf("Enter value of N:\t"); scanf("%d", &n); printf("Enter value of R:\t"); scanf("%d", &r); result = (float)Factorial(n) / Factorial(n - r); printf("\nValue of nPr:\t %.2f\n", result); return 0; }

#### Method 2: C Program To Find Value of nPr using While Loop

#include<stdio.h> int Factorial(int x) { int factorial = 1, count = x; while(count > 1) { factorial = factorial * count; count--; } return factorial; } int main() { int n, r; float result; printf("Enter value of N:\t"); scanf("%d", &n); printf("Enter value of R:\t"); scanf("%d", &r); result = (float)Factorial(n) / Factorial(n - r); printf("\nValue of nPr:\t %.2f\n", result); return 0; }

#### Output

If you have any compilation error or doubts in this C Program To Compute nPr with and without Functions, let us know about it in the Comment Section below.

This is just awesome! Thank you so much! I could finally complete my C Programming assignment! 🙂

Glad that the code could help you in academics! 🙂

I think that I can now convert most of my mathematical problems into C program codes now. 🙂

A Permutation is an arrangement of a number of objects in a definite order.