C++ Program to find Factorial of a number using For Loop In C++.

/*  Example Program For Factorial Value Using For Loop In C++  */

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

void 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();
 }

Sample Output

Enter the Number :6
6 Factorial Value Is 720

Post a Comment

Previous Post Next Post