A program to find factorial value for numbers between 1 and 10
C Programming Language 033
The following code shows how to write a program to find factorial value for numbers between 1 and 10.
Program
#include <stdio.h>
void main()
{
int i;
long int fact = 1;
for (i = 1; i <= 10; i++)
{
fact = fact * i;
printf("%d! = %ld\n", i, fact);
}
printf("\n");
}
Result
1! = 1
2! = 2
3! = 6
4! = 24
5! = 120
6! = 720
7! = 5040
8! = 40320
9! = 362880
10! = 3628800
Last Updated on
Comments