A seating label needs two numbers: a row and a seat within that row. A nested loop is a loop inside another loop. The outer loop selects a row; the inner loop visits every seat in that row.
#include <iostream>
int main() {
for (int row = 1; row <= 2; row = row + 1) {
for (int seat = 1; seat <= 3; seat = seat + 1) {
std::cout << row << ':' << seat << '\n';
}
}
return 0;
}
For row 1, the inner loop runs with seats 1, 2, and 3. Only after that inner loop finishes does the outer loop change the row to 2. A new inner loop then starts with seat 1 again. The first labels are 1:1, 1:2, and 1:3; the next row begins with 2:1.
There are two pairs of loop braces. Indentation helps you see which body contains which statements, but the braces determine the actual grouping. The output statement is inside both loops, so it runs once for each row-and-seat combination.
The example has two rows with three seats each; your task reverses those dimensions to three rows with two seats each. Both produce six labels, but the label sequences differ. Keep the supplied outer loop and add the inner loop at its TODO. Declare the seat counter in that inner loop's header so each new row begins again at seat 1.
Seat row-seat, using the current numbers. Print Seat 1-1 through Seat 3-2 in row order, one label per line.Edit main.cpp, press Run to inspect the Console, then Submit to check your work.