-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCPP Code
More file actions
34 lines (27 loc) · 666 Bytes
/
Copy pathCPP Code
File metadata and controls
34 lines (27 loc) · 666 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
//Permutations in which n people can occupy r seats
#include<stdio.h>
//function for factorial
int factorial(int num)
{
int fact=1;
for(int i=num; i>=1 ;i--)
fact*=i;
return fact;
}
//main program
int main()
{
int n,r;
printf("Enter number of people: ");
//user input
scanf("%d",&n);
printf("Enter number of seats: ");
//user input
scanf("%d", &r);
//finding all possible arrangements of n people on r seats
// by using formula of permutation
int p = factorial(r)/factorial(r-n);
//printing output
printf("Total possible arrangements: %d",p);
return 0;
}