## C Program to Find Factorial of a Number!

Here is another interesting program for school students who are interested in learning C programming. This program will calculate the factorials and print all the values as a factorial pyramid. Example (C Program to find factorial of a number):

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 |
#include <stdio.h> int main() { int num, fact = 1, i; //print about the program printf("C Program to calculate factorial..\n"); printf("Enter Number to calculate factorial: "); //get the input value from the user scanf("%d", &num); //loop till the iterator $i equals to $number for (i = 1; i <= num; i++){ //formula to calculate factorial is to //multiply the iterator i value with fact value. fact = fact * i; //print fact to show the factorial pyramid //or put this line out of this 'for loop' to show only the total value printf("%d\n", fact); } return 0; } |

## Recent Comments