I need to write a complete program using "While Loop" to calculate 1! to 12! using just "int" variables. Only from 1 to 12 and there are no other inputs..
This is my first time using While loop.
#include <iostream>
#include <iomanip>
int main()
{
constint MIN = 1 ;
constint MAX = 12 ;
int n = MIN ;
while( n <= MAX )
{
int factorial = 1 ;
int i = 2 ;
while( i <= n )
{
factorial *= i ;
++i ;
}
std::cout << std::setw(2) << n << "! == " << std::setw(9) << factorial << '\n' ;
++n ;
}
}