This program calculates the factorial of a given positive integer.
include<stdio.h>
int
main() {
int n, i;
unsigned
long
long factorial =
1;
printf(
"Enter a positive integer: ");
scanf(
"%d", &n);
for(i =
1; i <= n; ++i) {
factorial *= i;
}
printf(
"Factorial of %d = %llu\n", n, factorial);
return
0;
}
No comments:
Post a Comment