Factorial of a number in C
#include<stdio.h>
int main() {
int i, fact=1, num;
printf("Enter a number to find factorial: ");
scanf("%d", &num);
for(i=1; i<=num; i++) {
fact = fact*i;
}
printf("Factorial of %d is: %d", num, fact);
return 0;
}
Output
Enter a number to find factorial: 5
Factorial of 5 is: 120
0 Comments