C Program to calculate the Combinations and Permutations.

C Program to calculate the Combination and Permutations. Combination means way of selecting a things or particular item from the group or sets. nCr=n!/r!(n-r)!. Permutations means possible way of rearranging in the group or set in the particular order. Read more about C Programming Language .

/***********************************************************
* You can use all the programs on www.c-program-example.com
* for personal and learning purposes. For permissions to use the
* programs for commercial purposes,
* contact [email protected]
* To find more C programs, do visit www.c-program-example.com
* and browse!
*
* Happy Coding
***********************************************************/

#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 %dn", 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));
}
Read more Similar C Programs
Learn C Programming
Recursion
Number System

You can easily select the code by double clicking on the code area above.

To get regular updates on new C programs, you can Follow @c_program

You can discuss these programs on our Facebook Page. Start a discussion right now,

our page!

Share this program with your Facebook friends now! by liking it

(you can send this program to your friend using this button)

Like to get updates right inside your feed reader? Grab our feed!

(c) www.c-program-example.com