FINDING FACTORIAL (LOOP METHOD)

             FINDING FACTORIAL 

                (LOOP METHOD)

INPUT

#include <stdio.h>

int main()
{
    int num, i, fact = 1;
    printf("Enter the number you want the factorial of:\n");
    scanf("%d", &num);

    for (i = 1; i <= num; i++)
    {
        fact = fact * i;
    }
    printf("The factorial of %d is %d ", num,fact);

    return 0;
}

OUTPUT

Enter the number you want the factorial of: 4 The factorial of 4 is 24






Comments