C Program to Find ncR nPr

« Previous Program Next Program »

Find ncR and nPr in C

To find ncR and nPr in C programming, you have to ask to the user to enter the value of n and r to find the ncR and nPr to display the value of ncR and nPr.

C Programming Code to Find ncR nPr

Following C program to ask the user to enter the two number i.e., the value of n and the value of r, to find its ncR and nPr, then display the result on the screen:

/* C Program - Find ncR and nPr */
long int fact(int);   //function declaration
void main()
	int n, r;
	long int ncr, npr;
	printf("Enter the value of n : ");
	printf("Enter the value of 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);
long int fact(int x)          //defining the function or function definition
	int i, f=1;
	for(i=2; i<=x; i++)
	return f;

When the above c program is compile and executed, it will produce the following result:

c program find ncr npr

Same Program in Other Programming Language

You may also like same program in other programming languages:

« Previous Program Next Program »

Latest 5 Posts by CodesCracker


Quick Links
Signup - Login - Give Online Test