// direct approach to calculate 5! (factorial of 5) #include #include using namespace std; int x, i; int main() { i = 1; x = 1; x = x * i; i = i + 1; // x=1 i=2 x = x * i; i = i + 1; // x=1.2 i=3 x = x * i; i = i + 1; // x=1.2.3 i=4 x = x * i; i = i + 1; // x=1.2.3.4 i=5 x = x * i; i = i + 1; // x=1.2.3.4.5 i=6 cout << x << endl; }