C++ program for factorial of a number using loop

Posted on at


/* Example Program For Factorial Value Using For Loop In C++
little drops @ thiyagaraaj.com

Coded By:THIYAGARAAJ MP */

#include<iostream>
#include<conio.h>

using namespace std;

int main()
{

// Variable Declaration
int counter, n, fact = 1;

// Get Input Value
cout<<"Enter the Number :";
cin>>n;

//for Loop Block
for (int counter = 1; counter <= n; counter++)
{
fact = fact * counter;
}

cout<<n<<" Factorial Value Is "<<fact;
// Wait For Output Screen
getch();
return 0;

}



About the author

160