

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
C program to calculate the value of nPr?
Permutations, nPr can also be represented as P(n,r) is a mathematical formula to find the number of permutations. The formula of P(n, r) is n! / (n – r)!.
The number of permutations on a set of n elements is given by n! where “!” represents factorial.
Input:n=5;r=4; Output:120
Explanation
P(5, 4) = 5! / (5-4)! => 120 / 1 = 120 5!=1*2*3*4*5*=120
Example
#include<iostream> using namespace std; long int fact(int x) { int i, f=1; for(i=2; i<=x; i++) { f=f*i; } return f; } int main() { int n, r; long int npr; n=5; r=4; npr=fact(n)/fact(n-r); printf("%d",npr); }
- Related Questions & Answers
- Program to calculate the value of nPr in C Program
- Program to calculate value of nCr in C++
- C Program find nCr and nPr.
- C++ Program to calculate the value of sin(x) and cos(x)
- Program to Calculate the Perimeter of a Decagon in C program
- C program to calculate the standard deviation
- How to calculate the power exponent value using C#?
- C++ program to Calculate the Edge Cover of a Graph
- C program to calculate age
- C++ Program to Calculate Sum of Natural Numbers
- C++ Program to Calculate Power of a Number
- Program to calculate volume of Ellipsoid in C++
- C++ Program to calculate Bitonicity of an Array
- C++ Program to calculate the profit sharing ratio
- C++ Program to Calculate Standard Deviation
Advertisements