Sequence CS Thinking Example 3

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

Example 3

easy
What is the output? SET a = 10. SET b = a * 2. SET a = 0. OUTPUT b.

Solution

  1. 1
    Step 1: a = 10. b = 10 * 2 = 20. Then a is changed to 0, but b already holds 20.
  2. 2
    Step 2: Output: 20.

Answer

2020
Once b is assigned the value 20, changing a does not affect b. Variables store values at the time of assignment, not references to expressions.

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