Lab 01 — First Program Lab
Unit 01 · ~45–90 min · attempt before opening the solution · Unit index
The scenario
The registrar’s office prints a simple text student ID card for every new student. You are writing the printer.
Files
| File | Purpose |
|---|---|
starter/lab-01.cpp |
skeleton with // TODO markers — your starting point |
starter/lab-01-debug-it.cpp |
the same program with 4 seeded bugs — part 2 of the lab |
solution/lab-01-solution.cpp |
a complete solution — open only after your attempt |
Part 1 — Build the card printer
Requirements
- Print a card with: a title line
==== STUDENT ID ====; your name; a programme line (e.g.BS Data Science); a year line; and a closing border of the same width as the title. - Every output line ends with a newline (
\n). - The program compiles with zero warnings:
g++ -std=c++17 -Wall -Wextra lab-01.cpp -o lab-01 - Use at least one chained
<<statement (two pieces sent in one statement) — see Lesson 2.
Expected output (shape — your details differ):
==== STUDENT ID ====
Name : Ayesha Khan
Programme: BS Data Science
Year : First
=====================
Method (from the Study Guide): write the steps as comments first; compile after every line; grow the program one output line at a time.
Part 2 — Debug It
Open starter/lab-01-debug-it.cpp. It looks
like a working card program but contains 4 seeded bugs — a mix of
compile errors and a wrong-output mistake.
Rules of the hunt
- Find and fix the bugs by reading first; write down each bug before you fix it.
- Compile after each single fix — and watch how the error list shrinks (usually the first bug causes the later errors).
- Use a 3-step hint ladder if stuck: reread Lesson 2 §4 → check the error catalogue → then (only then) compare with the solution.
Done means: the debug file compiles warning-free and prints the card correctly, and you can say for each of the 4 bugs what it was and how the compiler told you (or didn’t, for the wrong-output bug).
Self-check (score yourself, /5)
- Card prints with correct shape and my details
- Compiles with zero warnings
- Used at least one chained
<< - All 4 Debug It bugs found, fixed, and explained in my own words
- My bug diary has ≥ 4 entries from this lab
Score 5/5 and quiz ≥ 90% → Unit 01 done (how scoring works).