+ 6

Write a program to get factorial of a given number using for loop.

28th Dec 2016, 7:40 AM
Ayush Jain
Ayush Jain - avatar
2 Answers
+ 12
#include <iostream> using namespace std; int main() { int counter, n, fact = 1; cout<<"Enter the Number :"; cin>>n; for (counter = 1; counter <= n; counter++) { fact = fact * counter; } cout<<n<<" Factorial Value Is :\n"<<fact; return 0; }
28th Dec 2016, 7:48 AM
elias sharafi
elias sharafi - avatar
17th Nov 2017, 9:39 AM
#RahulVerma
#RahulVerma - avatar