So far every program ran top to bottom. Control statements let the data choose which lines run.
1 if
Runs its block only when the condition in ( ) is true — otherwise it is skipped.
2 else
The other path — runs when the if condition above it failed.
3 else if
Chain checks in a ladder: the first true condition wins, the rest are skipped.
4 switch
Compares one value against many case labels — tidy for menus and choices.
5 break & default
break exits the switch; default runs when no case label matched.
Let the code decide
if1Runs its block only when the condition in ( ) is true — otherwise it is skipped.
else2The other path — runs when the if condition above it failed.
else if3Chain checks in a ladder: the first true condition wins, the rest are skipped.
switch4Compares one value against many case labels — tidy for menus and choices.
break & default5break exits the switch; default runs when no case label matched. 5 building blocks make up Let the code decide
A waterfall of checks: the first yes wins, and every later check is skipped.
process decision input / output start / end Two tabs: the if-else ladder grades marks, the switch runs a drinks menu.
preprocessThe preprocessor pastes in iostream for cout.
Memory
no variables yet — press play
Console
output appears as the program runs…
Click a keyword, then click the job it does.
5 conceptsTap a card to expand ?ifdrops into place
?elsedrops into place
?switchdrops into place
?breakdrops into place
?defaultdrops into place
One even/odd check, one skipped branch — trace it before you guess.
Your predicted output — one line per console line
Hint: 4 % 2 is 0, so even prints. n > 10 is false, so big is skipped — but done has no if, it always prints.
01if / else picks between paths; in a ladder the first true condition wins.
02switch compares one value to many cases — break stops fall-through.
03A condition is just an expression: true runs the block, false skips it.
04Without break, a matching case falls into the next one — usually a bug.