ADS

C Program To Find Factorial | C Programming

C Program To Find Factorial

#include <stdio.h>
int main()
{
    int n, i,factorial = 1;
    printf("Enter an integer: ");
    scanf("%d",&n);
    if (n < 0)
        printf("Error! Factorial of a negative number doesn't exist.");
    else
    {
        for(i=1; i<=n; ++i)
        {
            factorial *= i;
        }
        printf("Factorial of %d = %d", n, factorial);
    }
    return 0;
}

OUTPUT

Find Factorial Using C program

Post a Comment

0 Comments