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 
#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(); } 
Output
SFT (Shamil’s Flow Table )
Are you interested to Read about SFT(Shamil’s Flow Table)?
Let us see the factorial program with Shamil’s program flow table.
C program for factorial program
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 
#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(); } 
Output
Example of for loop to display the number as 5, 10, 15, 20, ……40, 45
1 2 3 4 5 6 7 8 9 10 11 12 13 
#include<iostream> #include<conio.h> using namespace std; int main() { int i; for(i=0;i<45;) { i=i+5; cout<<i; ; } } 
More Practice on Factorial problem in C++
 Factorial Program in C++
 factorial using single inheritance
 Factorial Program in C++ using Class Objects
 factorial using Multiple inheritances

C++ program for factorial using Constructor DestructorFactorial Of A Number By Using The Recursion  Factorial Program with structures and pointers C++
 Factorial Program with Nested Structure C++
 factorial of a no. by defining the member functions outside the class
Latest posts by Prof. Fazal Rehman Shamil (see all)
 What Is AssignCode and How Can It Help With Java Assignment?  May 27, 2021
 How to write a resume for a job search: Tips for applicants  May 11, 2021
 The Best Tool to Test the Speed of Your Internet  May 5, 2021