#include<stdio.h> #include<conio.h> long int fact(int); //function declaration void main() { clrscr(); int n, r; long int ncr, npr; printf("Enter the value of n : "); scanf("%d",&n); printf("Enter the value of r : "); scanf("%d",&r); npr=fact(n)/fact(n-r); // calling the function or function calling ncr=npr/fact(r); //function calling printf("NPR value = %ld\n",npr); printf("NCR value = %ld\n",ncr); getch(); } long int fact(int x) //defining the function or function definition { int i, f=1; for(i=2; i<=x; i++) { f=f*i; } return f; }
C program to find find ncR nPr.
Reviewed by
on
December 22, 2019
Rating:
No comments: