F Program to calculate Factorial of a Number in C++ | CodeTheta

Program to calculate Factorial of a Number in C++

September 29, 2018

Code : 
#include<iostream>
using namespace std;
int main(){
int number, factorial = 1, i;
cout<<"Enter a positive number: ";
cin>>number;
for(i=1;i<=number;i++) {
factorial = factorial *i;
}
cout<<"Factorial is: "<<factorial;
return 0;
}

Output :
Enter a positive number: 3
Factorial is:6

IDE Used To Test This Code : Dev C++.

Try this code in your computer for better understanding. Enjoy the code. If you have any Question you can contact us or mail us.We will reply you as soon as possible.

Post a Comment