Computers don't do magic — they follow steps, one at a time. In this lab you can slow those steps down, poke them, and see exactly what the machine is doing. Nine stations. Real C++. No installing anything.
Station 01
When a program needs to remember something, it asks for a box in memory, puts a label on it, and drops a value inside. In C++ you also say what kind of thing goes in the box — and the computer holds you to it. Type anything below and watch the same value land in five different kinds of box.
Type a value and press Store.
Press Try Hello and watch the char box: it keeps only the 'H' and throws
the rest away, because a char holds exactly one character. Note the quotes too — 'H' with single
quotes is one character, "H" with double quotes is a whole string. And look at the ASCII number
under it: a char really is just a small integer wearing a costume, which is why 'A' + 1 gives
you 'B'.
Station 02
An if is a fork in the road. The computer checks one question, and takes exactly one path. Drag the slider and watch which door opens.
Watch line 3 as you drag. >= means "greater than or equal to", so a score of
exactly 60 still passes. One tiny character changes who passes and who doesn't.
Station 03
Want to do something ten times? You don't write it ten times. A for loop keeps a counter, and repeats until the counter says stop. Press Run and watch BYTE walk the track — one lap per turn of the loop.
The counter starts at 1.
Station 04
One box holds one thing. An array is a whole row of boxes sharing a name, numbered from zero. Click a locker to open it.
Click any locker.
The first locker is scores[0], not scores[1]. Five lockers means the last one
is scores[4]. Nearly every programmer has been bitten by this — now you won't be.
Station 05
A function takes something in, does a job, and hands something back. Build it once, use it forever. Drop a number in the hopper and watch the gears turn.
Station 06
Here are five complete C++ programs. Step through them one line at a time and watch memory change and output appear. This is exactly what a debugger does, and it is the single best way to understand code that confuses you.
Station 07
An algorithm is just a recipe. Bubble sort's recipe is almost silly: look at two neighbours, and if they're in the wrong order, swap them. Repeat until nothing swaps. The biggest value "bubbles" to the end each pass. Watch it happen.
Press Play to start sorting.
Count the comparisons for 10 bars — it's about 45. For 100 bars it would be about 4,950. Bubble sort gets slow fast. That's why the next station matters so much.
Station 08
Guess my number between 1 and 100. Guessing 1, 2, 3… could take 100 tries. But guess 50 and I say "higher" — you just deleted half the numbers in one move. That's binary search, and it only works because the list is sorted.
Pick a number to hunt for.
Same list, same target. One checks every item in order; the other halves the list each time.
Run a hunt to compare.
Station 09
Eight questions. Wrong answers are fine — each one explains itself, so you learn either way. Scroll back up any time to check.
Ten perfect papers, one for each chapter. That is not luck — you understand this material. Go and write something with it.