Sequence CS Thinking Example 4

Follow the full solution, then compare it with the other examples linked below.

Example 4

easy
Trace this pseudocode: SET x = 2. SET y = x + 4. SET x = y * 2. OUTPUT x, y.

Solution

  1. 1
    Step 1: Start with x = 2. Then y = x + 4 = 6.
  2. 2
    Step 2: Next x = y * 2 = 12. The output is x = 12 and y = 6.

Answer

Output: x = 12, y = 6.
Sequence means instructions run in order. Each line uses the values produced by earlier lines, so changing the order would change the result.

About Sequence

Executing a series of instructions one after another in a fixed, specific order. In sequential execution, each instruction must complete before the next one begins, and the order in which statements appear determines the order in which they run.

Learn more about Sequence โ†’

More Sequence Examples