Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 394a89f

Browse files
Add files via upload
1 parent 5de4e77 commit 394a89f

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#include <stdio.h>
2+
int factorial(int n)
3+
{
4+
int f;
5+
for(f=1;n>1;n--)
6+
f=f*n;
7+
return f;
8+
}
9+
int npr(int n,int r)
10+
{
11+
return factorial(n)/factorial(n-r);
12+
}
13+
int ncr(int n,int r)
14+
{
15+
return npr(n,r)/factorial(r);
16+
}
17+
int main()
18+
{
19+
int n,r;
20+
21+
printf("Enter the value of n: ");
22+
scanf("%d",&n);
23+
printf("Enter the value of r: ");
24+
scanf("%d",&r);
25+
printf("\nPermutation of %dP%d = %d\n",n,r,npr(n,r));
26+
printf("Combination of %dC%d = %d\n",n,r,ncr(n,r));
27+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /