A two-dimensional table is a table where you choose a row and a column and read the value at the intersection. A multiplication table is a good example. Letβs say you wanted to print a multiplication table for the values from 1 to 6.
The first line initializes a variable named i, which is going to act as a counter, or loop variable. As the loop executes, the value of i increases from 1 to 6, and then when i is 7, the loop terminates. Each time through the loop, we print the value 2*i followed by three spaces. By omitting the endl from the first output statement, we get all the output on a single line.
Currently, the code below prints all of the multiples of three on one line. How can you change the output so that each multiple prints on its own line?
A newline character must be used in conjunction with a string. In this case, we are outputting an integer. To use a newline character in this scenario you must use quotes around it. (ex. "\n")
Change the second output statement to say cout << endl << endl;