C Program to Print the Factorial of a given number - 6 Players blogs for technology

give us your feedback

People Online

Breaking

ads

Post Top Ad

Friday, May 17, 2019

C Program to Print the Factorial of a given number



#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;
        }
    }
    printf("Factorial of %d = %5d\n", num, fact);
}

let say the number is 10 the output is
= 3628800

1 comment:

ads1

Post Top Ad