**Factorial Program in C, C++ (C Plus Plus, CPP) with flow chart**

In this tutorial, we will learn about the followings;

- Flowchart of the factorial program
- C++ program for factorial program
- C program for factorial program

**Logic of factorial**

Suppose we want to calculate the factorial of 4, then we need to perform the multiplication in such a way as given below;

4*3*2*1=24, so factorial of 4 is 24.

Similarly, suppose we want to calculate the factorial of 5, then we need to perform the multiplication in such a way as given below;

5*4*3*2*1=120, so factorial of 5 is 120.

**Flowchart of the factorial program**

**C++ program for factorial program**

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
<span style="font-size: 14pt; font-family: arial, helvetica, sans-serif;">#include<iostream> #include<conio.h> using namespace std; int main() { int i; int num; unsigned long long fact=1; cout<<"Please enter a number: "; cin>>num; for(i=1;i<=num;i++) { fact=fact*i; } cout<<"Factorial of entered number is: "<<fact; getch(); }</span> |

**Output**

**C program for factorial program**

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
<span style="font-size: 14pt; font-family: arial, helvetica, sans-serif;">#include <stdio.h> #include<conio.h> int main() { int i; int num; unsigned long long fact = 1; printf("Please Enter a number: "); scanf("%d",&num); for(i=1; i<=num;i++) { fact *= i; } printf("Factorial of Entered number is %llu", fact); getche(); }</span> |

**Output**