Midterm Review
"For the LORD gives wisdom; from his mouth come knowledge and understanding." — Proverbs 2:6
The Seven Chapters, Compressed
A one-paragraph reminder of each. If any of these don't ring a bell, re-read the relevant chapter before the exam.
- Ch 1 — The Sport.
cout,cin, the three pillars. The skill lives in your hands; reps are how it gets there. - Ch 2 — Types. Five types. The integer-division trap.
boolalpha. - Ch 3 — Conditionals.
if/else if/else.==not=. Always brace. - Ch 4 — Loops.
for/while/do…while. Off-by-one. Sentinels andbreak. - Ch 5 — Functions. Return type, parameters, return value. Pass-by-reference (
&). Composition. - Ch 6 — Arrays/Strings. Fixed-size + count. Indices 0 to size-1. Linear search returns index or -1.
- Ch 7 — Structs. Bundle related fields. Trailing semicolon on the declaration. Pass
const T&by default.
The Bug List
Tape this to your wall the morning of the exam:
- Integer division — cast at least one operand to
double. - Off-by-one —
<vs<=. =instead of==in an if.- Missing
break;inswitch. - Function modifies its parameter but the change "doesn't stick" — pass by value vs
&. - Missing
#includeat the top. - Comparing doubles with
==. - Uninitialized variable.
- Missing trailing semicolon on a struct declaration.
- Off-by-one starting a sum at 0 vs 1.
Exam Rules
60 minutes. Closed-book, closed-internet, closed-AI. The textbook itself (printed or non-interactive PDF) and your own past project files are permitted. The exam project is P8 — Mission Trip Simulator. Read the full spec on the project page.
Coach's Note — This is the first test where you cannot reach for AI. You will probably feel the absence acutely in the first ten minutes. That's normal. Hold the discomfort. The discomfort is the test working. If you've prepared honestly — typed the reps, written the projects, debugged your own bugs — the discomfort will pass. Your hands will start working.
How to Spend Your Last Week
- Days 1–2: Re-do 2–3 hardest reps from each Chapter 1–7.
- Days 3–4: Work through the combination drills in the Chapter 8 reps.
- Day 5: Do one full timed sample midterm. Open
code/sample_midterm.cpp, read the prompt, close the file, solve from blank in 60 minutes. - Day 6: Read your own past project code aloud. Re-do anything that surprises you.
- Day 7 (exam day): Light review only. Re-read the bug list above. Eat. Show up early.
What's on the Exam (general shape)
- Define one or more structs.
- Initialize an array of structs with a count variable.
- Run a loop updating state across iterations (often phases of a day).
- Apply conditional logic per element.
- Compute aggregate stats at the end.
- Print structured output.
That's the Mission Trip Sim. The actual prompt is sealed until exam time, but the shape is no secret.
Pre-Midterm Self-Check
int total = 0;
for (int i = 1; i <= 5; i++) {
if (i % 2 == 0) total += i;
}
cout << total; i = 1, 2, 3, 4, 5. The if accepts only even values: 2 and 4. So total = 2 + 4 = 6. This combines Pattern 3 (accumulator) and Pattern 6 (per-element decision) — two of the patterns the midterm tests. Citizen structs?// Remove citizens[i], where 0 <= i < count
//
// (A)
for (int j = i; j < count - 1; j++) {
citizens[j] = citizens[j + 1];
}
count--;
// (B)
for (int j = i; j < count; j++) {
citizens[j] = citizens[j + 1];
}
count--;
// (C)
citizens[i] = citizens[count - 1];
count--;