#include <stdio.h>
void main()
{
int i,fact=1,num;
printf(“Enter the number\n”);
scanf(“%d”,&num);
if( num <= 0)
fact = 1;
else
{
for(i = 1; i <= num; i++)
{
fact = fact * i;
}
} /* End of else */
printf(“Factorial of %d =%5d\n”, num,fact);
} /* End of main() */
/*——————————————-
Output
Enter the number
5
Factorial of 5 = 120
———————————————*/
Not Satisfied ? Just search & get the result
Related posts:
- C program to check whether a given number is prime or not and output the given number with suitable message
- C program to accept a decimal number and conert it binary and count the number of 1′s in the binary number
- C program to convert the given binary number into decimal
- C program to convert the given binary number into its equivalent decimal
- C program to convert the given binary number into its equivalent decimal
