In this program, we will learn how to find factorial of a given number using C++ program?Here, we will implement this program with and without using user define function.
#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
Program to find factorial using loop in C++
Output
need an explanation for this answer? contact us directly to get an explanation for this answer