Making a multiplication table using while loop

I have been working on this homework problem for quite a while now and I just can't figure out how to get the program to print out more than one column/row. I followed the instructions in the program, but obviously I have done something wrong. Why does it stop after 1 loop? rowCounter is less than the constant MAX(5), so shouldn't it loop until it reaches 5?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include<iostream>
#include<iomanip>
using namespace std;

int main()
{
    const int MAX = 5;

    // TODO: Declare a column counter, and
    //       declare and initialize a row counter
	int columnCounter;
	int rowCounter = 1;


    // TODO: Remove comment symbols, and write outer loop for MAX rows
    while(rowCounter <= MAX)
    {
        // TODO: Initialize column counter for each row
		columnCounter = 1;

        // TODO: Write inner while loop for MAX columns
		while(columnCounter <= MAX)
		{
            // TODO: Display the next product (row * col)
			cout << rowCounter * columnCounter << "\t";

            // TODO: Update the column counter
			columnCounter++;


		   // TODO: Print a new line, and
           //       update the row counter
			cout << "\n";
			rowCounter++;
		}


    }  // end of outer loop body

    cout << endl;
    cout << "\nDone for "
         << MAX << " by " << MAX
         << " table."<< endl;

    return 0;
}

/*

   1   2   3   4   5
   2   4   6   8  10
   3   6   9  12  15
   4   8  12  16  20
   5  10  15  20  25


Done for 5 by 5 table

*/



1
4
9
16
25


Done for 5 by 5 table.
Press any key to continue . . .
You seem to be incrementing the row AND column counters inside the loop; this isn't what you want. Can you see why?
Move the } at line 35 to line 30.

You want to end a row (cout << "\n") outside of the loop that prints the columns.
I got the program to work after Zhuge's response. Thanks, but I'm still trying to figure out why it matters if I have "rowCounter++;" inside the inner loop rather than in the outside loop.
Nevermind, I get it now. Thanks for the responses to help me understand it better.
Topic archived. No new replies allowed.