*Find nCr and nPr using function*

*Find nCr and nPr using function*

Write a C program to find nCr and nPr using function. Here’s simple program to find nCr and nPr using function in C Programming Language.

Below is the source code for C program to find nCr and nPr using function which is successfully compiled and run on Windows System to produce desired output as shown below :

**SOURCE CODE : :**

**SOURCE CODE : :**

/* C program to find nCr and nPr using function */ #include <stdio.h> long factorial(int); long find_ncr(int, int); long find_npr(int, int); int main() { int n, r; long ncr, npr; printf("Enter the value of n :: "); scanf("%d",&n); printf("\nEnter the value of r :: "); scanf("%d",&r); ncr = find_ncr(n, r); npr = find_npr(n, r); printf("\n%dC%d = %ld\n", n, r, ncr); printf("\n%dP%d = %ld\n", n, r, npr); return 0; } long find_ncr(int n, int r) { long result; result = factorial(n)/(factorial(r)*factorial(n-r)); return result; } long find_npr(int n, int r) { long result; result = factorial(n)/factorial(n-r); return result; } long factorial(int n) { int c; long result = 1; for (c = 1; c <= n; c++) result = result*c; return result; }

**OUTPUT : :**

**OUTPUT : :**

/* C program to find nCr and nPr using function */ Enter the value of n :: 4 Enter the value of r :: 2 4C2 = 6 4P2 = 12 Process returned 0

Above is the source code for C program to find nCr and nPr using function which is successfully compiled and run on Windows System.The Output of the program is shown above .

If you found any error or any queries related to the above program or any questions or reviews , you wanna to ask from us ,you may * Contact Us* through our contact Page or you can also comment below in the comment section.We will try our best to reach up to you in short interval.

**Thanks for reading the post….**