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.
Do this, then that, then the next thingβorder matters and each step must finish before the next.
Showing a random 20 of 76 problems.
Example 1
medium
Trace: x=4; y=xβx; x=1; print y. What prints?
Example 2
medium
Trace: SET x = 6. SET y = 4. SET x = x * y. SET y = x / y. OUTPUT x, y.
Example 3
easy
Trace this pseudocode: SET x = 2. SET y = x + 4. SET x = y * 2. OUTPUT x, y.
Example 4
hard
Trace: SET a = 3. SET b = a + 2. SET a = b * 2. SET b = a - b. OUTPUT a, b.
Example 5
easy
True or false: in pure sequence (no loops or ifs), each line runs exactly once.
Example 6
medium
Trace: L=[1,2]; L.append(3); L.append(L[0]); OUTPUT L.
Example 7
medium
Two students wrote the same recipe steps in different orders. Student A: (1) preheat oven, (2) mix batter, (3) pour into pan, (4) bake. Student B: (1) mix batter, (2) pour into pan, (3) preheat oven, (4) bake. Which version is more efficient and why?
Example 8
challenge
Lines: (1) total=0, (2) total=total+price, (3) read price. A developer wrote them as 1,2,3. Why is total wrong, and what is the fix?
Example 9
challenge
Given 4 statements S1β..S4β where S3β depends on S1β and S4β depends on S2β, how many valid total orderings exist?
Example 10
medium
Trace this swap attempt: SET a = 7. SET b = 2. SET a = b. SET b = a. OUTPUT a, b. Why doesn't this swap?Broken swap: a=b overwrites original a; both print 2
Example 11
medium
Trace: x=10; y=x/2; x=xβy; OUTPUT x.
Example 12
hard
A statement using z appears at line 3; z is assigned at line 7. Will the program work as written? Why or why not?
Example 13
medium
A recipe lists: (1) bake 30 min, (2) preheat oven, (3) mix batter. Why is order (2),(3),(1) correct rather than (1),(2),(3)?
Trace: s = 'ab'; s = s + 'c'; s = s + 'd'. Final s?
Example 17
medium
Using a temporary variable, write a correct swap of a and b assuming SET a = 7, SET b = 2 at the start. Then give the output of (a, b).Correct swap with temp variable: output a=2, b=7
Example 18
medium
Trace: SET x = 4. SET y = x + 2. SET z = y * x. SET x = z - y. OUTPUT x.
Example 19
easy
In a sequence of 3 statements with no loops or ifs, how many times does the middle statement run?
Example 20
medium
Trace: x=5; y=10; swap (no temp): x=x+y; y=xβy; x=xβy. Final x,y?