Final answer:
To print a rectangle given the number of rows and columns, you utilize nested loops; the outer loop for rows and the inner loop for columns. An example includes a for-loop in Python that prints an asterisk for each column per row, followed by a newline after each row is printed.
Step-by-step explanation:
To print a rectangle, you'll need to use nested loops, specifically, a for-loop inside another for-loop. The outer loop will run for the number of rows, while the inner loop will run for the number of columns. Below is an explanation and an example code snippet to achieve this task.
The first (outer) loop represents the rows and will iterate based on the number you specify for rows. The second (inner) loop represents the columns and will iterate according to the number you specify for columns. Inside the inner loop, you will print a character (like '*') to build a single row. After the inner loop completes one iteration (building one row), you need to print a newline character to move to the next line.
Answer
Here is the sample code in Python:
for i in range(2): # Outer loop for rows
for j in range(3): # Inner loop for columns
print('*', end='') # Print columns in one row
print() # New line after each row