5. if and for Statements

Printing Out Squares

Here is one example that you can probably figure out by yourself:

#include <iostream>
using namespace std;

int main()
{
    for(double i=1; i<=6; i++)
        cout << "The square of " << i << " is " << i*i << endl;
}

Type in and execute this program! You should get the following on standard output:

The square of 1 is 1
The square of 2 is 4
The square of 3 is 9
The square of 4 is 16
The square of 5 is 25
The square of 6 is 36