Write a program to calculate factorial of a number

In this example, you will learn to calculate the factorial of a number entered by the user.

write a program to calculate factorial of a number

To understand this example, you should have the knowledge of the following C programming topics:. The factorial of a negative number doesn't exist. And, the factorial of 0 is 1. This program takes a positive integer from the user and computes the factorial using for loop.

Search form

Since the factorial of a number may be very large, the type of factorial variable is declared as unsigned long long. You can also find the factorial of a number using recursion.

write a program to calculate factorial of a number

Course Index Explore Programiz. Popular Tutorials Data Types in C. C for Loop. Arrays in C Programming. Pointers in Proggram. Find roots of a quadratic equation.

You are here

Print Pyramids and Patterns. Check prime number. Print the Fibonacci series. Reference Materials string. Learning Paths.]

write a program to calculate factorial of a number