C Programming
- Print integer
- Add & subtract
- Odd & even
- Multiply & divide
- Check vowels
- Letter grade program
- Leap year program
- Sum of digits
- Prime numbers
- Sum of numbers
- Find factorial
- Fibonacci series
- Fibonacci triangle
- Number triangle
- Alphabet triangle
- Armstrong numbers
- Palindrome numbers
- Swap number
- Reverse number
- Decimal to binary
- Assembly code in C
- Matrix multiplication
- HCF & LCM
- nCr & nPr
- Print pattern
- Floyd’s triangle
- Pascal triangle
- Count digits
- Strong numbers
- Perfect numbers
- Sum of natural number
- Binary to decimal
- Decimal to octal
- Octal to decimal
- Binary to octal
- Octal to binary
- Add using pointer
- Bubble sort
- Insertion sort
- Selection sort
- Quick sort
- Binary search
- Linear search
- Largest element of array
- Smallest element of array
- Reverse Array
- Variable size & limit
- ASCII value of character
- Sum of array elements
- Number of element in array
- Merge two array
- Insert element in array
- Delete element from array
- Add two matrix
- Transpose matrix
- Print string
- Reverse string
- Delete vowels
- Sort string
- Remove spaces
- Swap string
- Random numbers
- Print date & time
- Print IP address
- Shut down computer
Find nCr and nPr using C program
We can find nCr and nPr using C program. Here we have given the C program to find the nCr and nPr. Before going ahead we should know what is nCr and nPr. nCr is used for determine the combination where nPr used for determine the Permutation.

C program to find nCr and nPr
// C program to find nCr and nPr
#include <stdio.h>
long findFact(int);
long findNcr(int, int);
long findNpr(int, int);
int main(){
int r, n;
long npr, ncr;
printf("Enter the value of n : ");
scanf("%d",&n);
printf("Enter the value of r : ");
scanf("%d",&r);
ncr = findNcr(n, r);
npr = findNpr(n, r);
printf("\n%dC%d is = %ld\n", n, r, ncr);
printf("%dP%d is = %ld\n", n, r, npr);
return 0;
}
long findNcr(int n, int r){
long result;
result = findFact(n) / (findFact(r) * findFact(n - r));
return result;
}
long findNpr(int n, int r){
long result;
result = findFact(n) / findFact(n - r);
return result;
}
long findFact(int n) {
int i;
long result = 1;
for (i = 1; i <= n; i++){
result = result * i;
}
return result;
}
Output of nCr and nPr program:
Enter the value of n : 15
Enter the value of r : 5
15C5 is = 4
15P5 is = 552
Previous page: HCF and LCM by C
Next page: Pattern printing in C