Program to Calculate the Factorial of any Number using for loop - C++ Programming

Calculate the Factorial of any Number:


Program:


#include <iostream>
using namespace std;
int main()
{
   int n;
   cout << "Enter the value of n" << endl;
   cin >> n;


   int fact = 1;
   for (int i=1 ; i<=n ; i++)
   {
       fact = fact*i;
    }
    cout << "fact = " << fact << endl;
    return 0:
}

Comments

Popular posts from this blog

How to display the output in C++