Write a program to find the factorial from 1 to 10 using nested loop?

#include <stdio.h>
int main() {
    int n, i;
    unsigned long long fact = 1;
    printf("Enter an integer: ");
    scanf("%d", &n);

    // shows error if the user enters a negative integer
    if (n < 0)
        printf("Error! Factorial of a negative number doesn't exist.");
    else {
        for (i = 1; i <= n; ++i) {
            fact *= i;
        printf("Factorial of %d = %llu", n, fact);

    return 0;

The output of the above program is

Enter an integer: 10
Factorial of 10 = 3628800
If you found any type of error on the answer then please mention on the comment or report an answer or submit your new answer.
Leave your Answer:

Click here to submit your answer.

Notify of
Inline Feedbacks
View all comments