41-Write a program to find the factorial of a number.

Program: 41

Write a program to find the factorial of a number.

#include
#include
void main()
{
    int num, i, fact=1;
    printf("Enter any number: ");
    scanf("%d", &num);
    for(i=num;i>=1;i--)
    {
        fact=fact*i;
    }
    printf("The factorial of %d is %d.", num, fact);
    getch();
}
Output
Enter any number: 5

The factorial of 5 is 120.

Lokesh Kumar: Being EASTER SCIENCE's founder, Lokesh Kumar wants to share his knowledge and ideas. His motive is "We assist you to choose the best", He believes in different thinking.
Related Post
Leave a Comment

This website uses cookies.