In this tutorial, we will see a new concept that is C Program to **Calculate Permutation and Combination**.

**Permutation formula:** Permutation means an arrangement of the things. When we say arrangement then we consider the order of the things.

We calculate permutation formula, given as follow

**npr function**

Number of permutation of **‘n‘** different things taken **‘r’** at a time is given by,

** ^{n}p_{r} = n!/(n-r)!**

**Example:** Suppose we have to form the number of consisting of three digits using the digits 1, 2 3,4. To form this number the digits have to be arranged. The different number will get formed depending upon the order in which we arrange the digits.

**Combination formula:** Combination means selection of the things. The order of things are considered where word selection is not important.

We calculate combination by formula , given as follow

^{n}C_{r = }n! / (n-r)! . r!

**Example:** Suppose that we have to make a team of 11 out of the members 20.

This is an example of the combination because an order of the member will not result in a change in the team that is no matter. No matter in which order we choose and male a order of the team only making the team of 11 is important.

## C Program to Calculate Permutation and Combination

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
#include<stdio.h> #include<conio.h> long fact (int); long find_com(int , int); long find_per(int , int); main() { int n,r; long ncr,npr; printf(“\n Enter the value of n and r:”); scanf(“%d”,&n,&r); ncr=find_com(n,r); npr=find_per(n,r); printf(“\n %dC%d = %d \n”,n,r,ncr); printf(“\n %dP%% = %d \n”, n ,r , npr); return 0; } long find_com(int n,int r){ long res; res= fact (n) /(fcat(r)* fcat(n-r)); return res; } long find_ per(int n ,int r) { long res; res= fact (n)/ fact (n-r); return res; } long fact(int n){ int c; long res =1 ; for(c=1;c<=n;c++) res = res *c ; return (res); } |

### Combination calculator

**Output :**

**Enter the values of n and r :**

** 5**

**2**

**5C2 = 10**

**5P2 = 20**