Skip to content

Commit 62d127c

Browse files
authored
Merge pull request ashutosh97#16 from ankugarg25/master
factorial of a number
2 parents 8985327 + b35eb6f commit 62d127c

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Ques:How to find a factorial of a number
2+
i am just giving you some hint.
3+
fact=fact*i
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#include <stdio.h>
2+
3+
int main()
4+
{
5+
int c, n, fact = 1;
6+
7+
printf("Enter a number to calculate its factorial\n");
8+
scanf("%d", &n);
9+
10+
for (c = 1; c <= n; c++)
11+
fact = fact * c;
12+
13+
printf("Factorial of %d = %d\n", n, fact);
14+
15+
return 0;
16+
}

0 commit comments

Comments
 (0)