For Loop in C++

Example of For loop:

#include <iostream>

using namespace std;

int main()

{

int i, n;

int factorial= 1;

cout << “Enter a number: “;

cin >> n;

for (i= 1; i <= n; ++i) {

factorial*= i;

}

cout<< “Factorial of “<<n<<” = “<<factorial;

return 0;

}