The code you've provided for the procedure drawSquare(size)
primarily uses iteration.
Here's why:
-
Iteration: The
FOR
loop iterates four times (from 1 to 4) to draw the four sides of the square. This is a classic example of using a loop to repeat a block of code. -
Sequencing: This is also present in the sense that the actions within the loop (the
forward(size)
andturnLeft(90)
) are executed in a specific order during each iteration. However, sequencing itself is a fundamental concept that is present in most programming constructs. -
Selection: This does not appear in the provided code. Selection usually involves conditional statements (like
if
orswitch
), which determine which paths of execution to take based on certain conditions.
In summary, the primary control structure demonstrated in your procedure is iteration.