awesome-everything RU
↑ Back to the climb

Base CS from zero

Control flow: multiple-choice review

Crux Multiple-choice synthesis across the control-flow unit: the program counter, conditional jumps and flags, fall-through, backward jumps, and why loops repeat or run forever.
Your altitude — climbing toward senior
ZeroJuniorMiddleSenior
You are at middle altitude — in the sky
◷ 13 min

Six questions that cut across the whole unit. None asks for a definition. Each asks you to reason about what the program counter does next — which is the single question every branch and every loop reduces to.

Goal

Confirm you can connect the four lessons into one model: the program counter drives flow, a compare sets flags, a conditional jump reads one flag bit, a backward jump repeats the body, and an if/else is just two destinations for the PC.

Quiz

Two running machines hold identical instruction bytes at identical addresses, yet they execute completely different sequences of instructions. How is that possible?

Quiz

A CMP R0, R1 executes, then a JNE (jump if not equal) is reached. Which single piece of state does the JNE actually inspect to decide jump-or-fall-through?

Quiz

An if/else compiles to: CMP; conditional-jump-to-ELSE; if-true block; unconditional JUMP to END; ELSE: if-false block; END. Why is the unconditional JUMP after the if-true block necessary?

Quiz

At the machine level, what is the only structural difference between a compiled while loop and a compiled for loop?

Quiz

A countdown loop decrements a counter and should exit when it hits 0, but it never exits and pins the CPU at 100%. Which explanation is consistent with how the machine actually runs the loop?

Quiz

In sumPositives over [3, -1, 4], the inner if skips the negative element. When nums[i] is non-positive, what does the machine do, and does the loop end early?

Recap

The whole unit is one through-line: the program counter decides what runs next, and only a jump can change it. A compare sets a flag; a conditional jump reads that one flag and either jumps or falls through; an if/else is two PC destinations with a skip-JUMP guarding the boundary; a loop is a backward jump whose conditional test at the top decides whether to fall into the body again; and a loop runs forever when the tested value never changes. Every branch and loop you will ever read reduces to one question: where does the PC point next, and why.

Continue the climb ↑Control flow: free-recall review
shortcuts expand
search
K
prev piece
k
next piece
j
cycle tier
t
this menu
?
sources3
expand
  1. 01
  2. 02
  3. 03

Trademarks belong to their respective owners. Editorial reference only.