Welcome to our blog post In this program, we will learn program how to find factorial of a given number using C++ program? Here, we will implement this program with and without using user define function.
Logical Part of program:
- Input a number
- Initialize the factorial variable with 1
- Initialize the loop counter with N (Run loop from number (N) to 1)
- Multiply the loop counter’s value with factorial variable
#include <iostream>
using namespace std;
int main()
{
int num,i;
long int fact=1;
cout<<“Enter an integer number: “;
cin>>num;
for(i=num;i>=1;i–)
fact=fact*i;
cout<<“Factorial of “<<num<<” is = “<<fact<<endl;
return 0;
}
Output :-
Enter an integer number: 6
Factorial of 6 is = 720
Related Post:-
So I hope that you learn about the How to find factorial of a given number using C++ program.And if you have any more queries about computer relegated then feel free to discuss your problem in the comment section.
Thank you so much and come back for more updates about Techgsr.co