In this tutorial, we will see a new concept that is C Program to Calculate Permutation and Combination.
Permutation : It means an arrangement of the things. When we say arrangement then we consider the order of the things.
Formula to calculate permutation
We calculate permutation formula, given as follow
Number of permutation of ‘n‘ different things taken ‘r’ at a time is given by,
npr = 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 : It means selection of the things. The order of things are considered where word selection is not important.
Formula to calculate Combination
We calculate combination by formula , given as follow
nCr = 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.
Concept you need to know from c
C Program to Calculate Permutation and Combination
12345678910111213141516171819202122232425262728 | #include <stdio.h>#include <conio.h>main() { int n , r, ncr( int , int); long npr( int , int); long double fact( int); printf(” Enter value of n & r \n”); scanf(“%d %d”,&n , &r); if( n>= r) { printf( ” %dC%d is %d\n”, n,r,ncr( n , r)); printf(” %dP%d is %ld”, n,r,npr( n, r)); } else { printf(“WRONG INPUT?? enter the correct input”); }}long double fact( int p) { long double facts = 1; int i; for ( i = 1; i<= p; i++) facts = facts * i; return( facts);}int ncr ( int n, int r) { return( fact( n) / (fact( r) * fact(n- r) ) ) ;}long npr( int n , int r) { return( fact( n) / fact( n- r));} |
Output :

Explanation :
1. write main function.
2. Declare variable.
3. Take input n and r.
4. Calculate permutation and combination.
5. Print permutation and combination.