CS U111 · Lab-eval ladder · Stage 0

Syntax bootcamp: from a blank file to a running program

The skeleton, the compile line, printf/scanf, and arithmetic, plus a decoder for the twelve compiler messages you will meet most, how a VPL lab evaluation runs your program, and ten broken programs to fix. Then thirteen problems on input, output and arithmetic in four rungs, each with 5 test cases like a real evaluation.

Start here

What this stage covers. Only the mechanics: typing a program that compiles, reading input, printing output, doing arithmetic. No loops yet. That's Stage 1.

Where it sits. This is the material of Lecture 2 (From algorithms to C programs) and Labs 1–2. Lab Sheet 4 assumes all of it from its first page: "A user enters a value, the program performs some action/calculation, and then terminates." Every lab evaluation question begins with the same six-line skeleton and a scanf. When a blank file feels hard to start, the usual reason is that these mechanics aren't automatic yet. That part can be drilled, and this page drills it.

The rungs. A (warm-up): one read, one calculation, one print. A+ (input patterns): the two input/output facts every evaluation relies on. B (VPL level): the arithmetic lines that sit inside real evaluation programs, in the evaluations' format. The instructor's real evaluations start at if/else, so the rung calibrated against them is Stage 1's B; this page's B is the step before. C (optional): validation and overflow, longer than any evaluation program.

Time budget: about 4½ hours without Rung C, best split over two or three sittings. Kit, skeleton and compile loop: 30 min. Formats and division: 25 min. Error decoder: 30 min. How VPL marks you: 15 min. Fix-it drill: 45 min. Rung A: 30 min. Rung A+: 20 min. Rung B: about 1¼ hours, including running the tests. Rung C adds about 1½ hours.

How to use it. Every program goes into a real file and gets compiled and tested. Reading doesn't count. For each problem, try it before opening anything; if you're stuck for 5 minutes, open only "Stuck? First move", then try again.

How these are marked

Every program on this page reads its input silently and prints only the answer, as VPL requires. Each problem card has 5 tests. Check one with Copy input → run your program → paste its output → Check. Or press Download test script, save it next to your .c file and run sh s0-a1-tests.sh a1.c in Terminal to run all five at once (it compiles with cc -Wall -Wextra). The full explanation is in How a lab evaluation runs your program.

Syntax you need for this stage

Everything on this page uses only these lines. For first-time teaching, see Lecture 2 and the Mac setup lesson; for operators and if, see the operators & selection lesson.

FormMeaning
int n; double x; char c;Declare a box for a whole number, a real number, one character.
int count = 0;Declare and give a starting value in one go.
long long big;A whole number with room up to about 9.2 × 1018 (an int stops near 2.1 × 109).
x = expression;Work out the right side, store it in x. Not "equals" in the maths sense.
printf("Sum: %d\n", s);Print text; %d is replaced by the value of s; \n ends the line.
scanf("%d", &n);Read a whole number from the keyboard into n. Note the &.
+ - * / %Arithmetic. / between two ints throws away the fraction; % is the remainder.
(double)a / bA cast: treat a as a real number for this one calculation.
if (cond) { … } else { … }Rung C only, for rejecting bad input. Fully covered in Stage 1.
a < 0 || a > 23|| = "or", && = "and".
scanf(…) != 1scanf returns how many values it actually read; anything less means bad input (Rung C).
return 0; / return 1;Leave main: 0 means "finished normally", non-zero means "stopped because of an error". Rung C prints an error word and then uses return 0; to stop early, since in an evaluation only the printed output is compared.

1 · The skeleton: type it from memory three times

Every program in this course starts with these six lines. Lecture 2 writes int main(); the lab sheets write int main(void). Both are fine, so pick one and always use it.

#include <stdio.h>

int main(void) {

    return 0;
}
LineWhy it's there
#include <stdio.h>Brings in printf and scanf (standard input/output). Without it the compiler refuses to compile (decoder entry 6).
int main(void) {The program starts running here. The { opens its body.
(blank line)Your code goes here, indented 4 spaces.
return 0;"Finished normally."
}Closes main. Every { needs exactly one }.
The drill (10 minutes, today)

Make a folder ladder0. Type the skeleton into skel.c with a printf("ok\n"); in the middle, compile, run. Close the file, delete it, and type it again without looking. Three clean compiles in a row from memory and the skeleton is done. Then do the same once at the start of each study session for a week, as a warm-up.

2 · The compile-and-run loop

This is the same command as in the Mac setup lesson, with one addition: && ./prog runs the program straight away, but only if the compile succeeded.

% gcc -Wall -Wextra -std=c11 -o prog prog.c && ./prog

On your Mac gcc is really clang (the setup lesson explains why). The messages quoted on this page come from that compiler, so they match what you'll see. The lab's Linux gcc words them differently but gives the same line numbers.

  1. Save (⌘S). The compiler reads the file on disk, not what's on the screen.
  2. ↑ then Return in the terminal: brings the command back, so you never retype it.
  3. No output from the compiler = clean. Any warning: line counts as a bug to fix before trusting the run.
  4. Errors: fix the first one only, then compile again. Later errors are often knock-on effects of the first.
  5. Program stuck? It is probably waiting for input (type some), or looping forever: press Ctrl+C to kill it.
Unpack: what exactly does && do in the terminal?

It's the shell's "and then, if that worked". The compiler reports success or failure when it exits; && runs ./prog only on success. Without it, a failed compile would quietly re-run the old prog and fool you.

3 · printf / scanf formats

TypeprintfscanfNote
int%d%d, &nThe everyday choice.
long long%lld%lld, &nFor results that overflow int (Rung C2).
float%f%f, &xLecture 2 uses it; prefer double (more precise).
double%f%lf, &xThe one asymmetry: %f to print, %lf to read (decoder 7).
char%c" %c", &cThe space before %c skips the leftover Enter (fix-it 5).
string (char s[50])%s%s, s (no &)Reads one word. Strings come in Stage 4.

The & rule. scanf needs to know where each variable lives, so every variable gets an &: scanf("%d %d", &a, &b);. The one exception is a string (an array), which already is a location. printf needs only the values, so it never takes &.

Unpack: what does & actually give scanf?

&n is "the address of n", i.e. where n lives in memory. Given only n's current (garbage) value, scanf would try to write to that random spot. That's the crash in decoder entry 3.

What scanf does with spaces. %d, %lf and %s skip spaces and Enters before the value, so 3 8, 3   8 and 3-Enter-8 all work for "%d %d". %c is the exception: it takes the very next character, even an Enter, unless you write " %c". Any other character in the format must be typed exactly: "%d:%d" wants 9:30.

Width and decimals (real output):

printfValuePrintsUse
%.2f2.3452.35Money, averages: 2 decimals
%5d42[   42]Right-align in 5 columns (tables)
%-5d42[42   ]Left-align in 5 columns
%02d707Clock times: 09:05
%04d10001Keep leading zeros (Rung B2)
%8.3f3.14159[   3.142]Width 8, 3 decimals
%%%A literal percent sign

4 · Integer vs real division, %, casts

The single rule: if both sides of / are integers, the answer is an integer, and the fraction is thrown away. One real number on either side makes it real division. All of these are from a real run:

ExpressionResultWhy
7 / 23int / int: fraction dropped
7 % 21remainder: 7 = 3 × 2 + 1
7.0 / 23.500000one side real → real division
(double)a / b3.500000cast happens first, then divide (a = 7, b = 2)
(double)(a / b)3.000000divide first (3), then cast: too late
1 / 2 * 4.00.000000left to right: 1 / 2 is 0 already
4.0 * 1 / 22.0000004.0 * 1 is real, so / 2 is real
-7 / 2-3C chops toward zero, not down
-7 % 2-1remainder takes the sign of the left side
(int)3.993a cast to int chops, it does not round
(int)(3.99 + 0.5)4add 0.5 then chop = round (for positive numbers)
'A' + 166a char is a small number ('A' is 65)

Two jobs for / and % that you'll use constantly: splitting a quantity into units (3725 / 3600 = 1 hour, 3725 % 3600 = 125 s left over), and peeling digits (n % 10 = last digit, n / 10 = drop the last digit). Rungs B1 and B2 are built on them.

Classic trap

double avg = (a + b + c) / 3; still does integer division: the right side is worked out before it is stored, and it is all integers. Storing into a double doesn't fix it. Write / 3.0. Fix-it 1 is exactly this bug.

5 · The compiler error decoder

Every message below was produced by compiling the code shown with gcc -Wall -Wextra -std=c11 on a Mac. How to read one: prog.c:5:26: error: means file prog.c, line 5, column 26. An error means no program was built. A warning means a program was built, but it's probably wrong. The ^ line points at the spot, and often there's a note: with the fix.

1 · Missing semicolon

You wrote
    printf("n = %d\n", n)
    return 0;
Compiler says
prog.c:5:26: error: expected ';' after expression
    5 |     printf("n = %d\n", n)
      |                          ^
      |                          ;
1 error generated.

Plain words: the statement on line 5 never ended. Fix: add ; where the caret points. clang points just past the end of the guilty line; Linux gcc often names the next line instead. So when an error makes no sense on the line it names, look at the end of the line above.

2 · Undeclared identifier (a typo, or forgot to declare)

You wrote
    int total = 0;
    totl = total + 10;
Compiler says
prog.c:5:5: error: use of undeclared identifier 'totl'; did you mean 'total'?
    5 |     totl = total + 10;
      |     ^~~~
      |     total
prog.c:4:9: note: 'total' declared here
    4 |     int total = 0;
      |         ^
1 error generated.

Plain words: "I've never heard of totl." Either it's misspelt (clang even suggests the right name) or you never wrote int totl;. Fix: correct the spelling or add the declaration above the first use. C is case-sensitive: Total and total are different names.

3 · Missing & in scanf (warning, then a crash)

You wrote
    int age;
    scanf("%d", age);
Compiler says
prog.c:5:17: warning: format specifies type 'int *' but the argument has type 'int' [-Wformat]
    5 |     scanf("%d", age);
      |            ~~   ^~~
prog.c:5:17: warning: variable 'age' is uninitialized when used here [-Wuninitialized]
    5 |     scanf("%d", age);
      |                 ^~~
And if you run it anyway
% ./prog
25
zsh: segmentation fault  ./prog

Plain words: %d wants "where to put an int" (int *) and you gave it an int. Fix: scanf("%d", &age);. "Segmentation fault" means the program touched memory it doesn't own. In a beginner program, a missing & is the first thing to check.

4 · = where you meant ==

You wrote
    if (n = 0)
        printf("zero\n");
Compiler says
prog.c:6:11: warning: using the result of an assignment as a condition without parentheses [-Wparentheses]
    6 |     if (n = 0)
      |         ~~^~~
prog.c:6:11: note: place parentheses around the assignment to silence this warning
    6 |     if (n = 0)
      |           ^  
      |         (    )
prog.c:6:11: note: use '==' to turn this assignment into an equality comparison
    6 |     if (n = 0)
      |           ^
      |           ==
1 warning generated.

Plain words: n = 0 stores 0 in n (and the condition becomes 0, i.e. false, every time). Fix: == to compare. It's only a warning, so the program runs and silently prints nothing, even for input 0.

5 · A missing closing brace

You wrote
int main(void) {
    int n;
    scanf("%d", &n);
    if (n > 0) {
        printf("positive\n");
    return 0;
}
Compiler says
prog.c:9:2: error: expected '}'
    9 | }
      |  ^
prog.c:3:16: note: to match this '{'
    3 | int main(void) {
      |                ^
1 error generated.

Plain words: the compiler reached the end of the file with a { still open. The line it names (the last line) is not where the mistake is. Fix: find the { that never got its }, here the if's. Habit that prevents this: type { and } together, then fill in between. VS Code highlights the matching brace when the cursor is next to one.

6 · Implicit function declaration (missing #include, or a misspelt function)

You wrote (no #include <stdio.h> at the top)
int main(void) {
    printf("Hello\n");
Compiler says
prog.c:2:5: error: call to undeclared library function 'printf' with type 'int (const char *, ...)'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
    2 |     printf("Hello\n");
      |     ^
prog.c:2:5: note: include the header <stdio.h> or explicitly provide a declaration for 'printf'
1 error generated.
Same family: a misspelt function name, prinf("%d\n", n);
prog.c:5:5: error: call to undeclared function 'prinf'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
    5 |     prinf("%d\n", n);
      |     ^
prog.c:5:5: note: did you mean 'printf'?

Plain words: "you're calling a function I haven't been told about." Fix: add the #include (<math.h> for sqrt/pow, <stdbool.h> for bool) or fix the spelling. On the Mac this is an error; Linux gcc before version 14 only warns, so in the lab it may compile and then misbehave. Don't ignore it there either.

7 · %f to read a double

You wrote
    double price;
    scanf("%f", &price);
    printf("%.2f\n", price);
Compiler says
prog.c:5:17: warning: format specifies type 'float *' but the argument has type 'double *' [-Wformat]
    5 |     scanf("%f", &price);
      |            ~~   ^~~~~~
      |            %lf
1 warning generated.
And if you run it anyway
3.5
0.00

Plain words: %f fills a float-sized box; a double is a bigger box laid out differently, so the value comes out as garbage. Fix: %lf in scanf for a double, exactly as the note suggests.

8 · Format / argument type mismatch in printf

You wrote
    double avg = (a + b) / 2.0;
    printf("Average: %d\n", avg);
Compiler says
prog.c:6:29: warning: format specifies type 'int' but the argument has type 'double' [-Wformat]
    6 |     printf("Average: %d\n", avg);
      |                      ~~     ^~~
      |                      %f
1 warning generated.
And if you run it anyway
Average: 0

Plain words: the format code and the value disagree about the type. The run prints garbage instead of 4.5, and the garbage can change from run to run. Fix: match them: %d ↔ int, %f ↔ double, %c ↔ char. The reverse mistake, %f with an int, gives the same warning.

9 · Unused variable

You wrote
    int n, square;
    scanf("%d", &n);
    printf("%d\n", n * n);
Compiler says
prog.c:4:12: warning: unused variable 'square' [-Wunused-variable]
    4 |     int n, square;
      |            ^~~~~~
1 warning generated.

Plain words: harmless by itself, but it often means you planned a step and forgot it, or are printing the wrong variable. Fix: use it or delete it. Either way, end with a clean compile.

10 · Variable used before it has a value

You wrote
    int length = 4, area;
    printf("Area: %d\n", area);
    area = length * length;
Compiler says
prog.c:5:26: warning: variable 'area' is uninitialized when used here [-Wuninitialized]
    5 |     printf("Area: %d\n", area);
      |                          ^~~~
prog.c:4:25: note: initialize the variable 'area' to silence this warning
    4 |     int length = 4, area;
      |                         ^
      |                          = 0
1 warning generated.

Plain words: a fresh variable holds whatever bits were lying in memory, so its value is garbage. Here the print happens before the calculation. Fix: compute before you print; start every sum/count at 0.

Watch out: the compiler does not always catch it. Lab 4's Debugging Exercise 3 (int sum; then sum = sum + i; inside a for loop) compiles with no warning at all under -Wall -Wextra, and on one run here it printed -192364441. Initialising every accumulator is your job, not the compiler's.

11 · Curly quotes from a PDF or chat

You pasted
    printf(“Hello\n”);
Compiler says
prog.c:4:12: error: unexpected character <U+201C>
    4 |     printf(“Hello\n”);
      |            ^
prog.c:4:15: error: use of undeclared identifier 'Hello'
    4 |     printf(“Hello\n”);
      |             ^~~~~
prog.c:4:22: error: character <U+201D> not allowed in an identifier
    4 |     printf(“Hello\n”);
      |                    ^
3 errors generated.

Plain words: “ ” are typographic quotes, not the " key. Three errors, one cause. Fix: retype the quotes. When you copy code out of a lab sheet PDF, also check for ‘ ’ and odd spaces (the sheet's % d and \ n are spacing artefacts of the PDF: type %d and \n).

12 · A linker error: main misspelt

You wrote
int mian(void) {
Compiler says
Undefined symbols for architecture arm64:
  "_main", referenced from:
      <initial-undefines>
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Plain words: there's no line number because the compile itself worked. It's the final step (linking) that failed: there is no function called main to start the program from. Fix: spell it main. The same message appears if you compile a file that has no main at all, e.g. the wrong file.

How a lab evaluation runs your program

Lab evaluations in this course are marked automatically by Moodle's VPL (Virtual Programming Lab). Nobody reads your program or watches it run. This is what happens when you press Evaluate:

  1. VPL types the input for you. Each test case has a fixed input, and VPL feeds it to your program's scanf calls (this is called standard input, or stdin) exactly as if someone had typed it and pressed Enter.
  2. It collects everything your program prints and compares it with the expected output, token by token. A token is anything between spaces or line breaks: BOXES 3 LEFT 2 is four tokens.
  3. What is forgiven: letter case (even matches EVEN) and spacing (one space, three spaces or a line break between tokens are all the same).
  4. What is not: every word, number and punctuation mark must match. 18.3 is not 18.33; Result: is not Result; one extra word anywhere fails the test.
  5. 5 test cases, −14 % for each one that fails. The statement shows a sample; the tests also aim at edge cases (0, boundaries, equal values, the largest value).

Three rules follow directly, and every program on this page obeys them:

Testing on your Mac, three ways

Each problem below has 5 test cases, like VPL. Compile first (gcc -Wall -Wextra -std=c11 -o a1 a1.c), then use whichever way suits:

  1. Type it. Run ./a1; nothing appears, because the program is silently waiting. Type the test input and press Return. Compare what it prints with the expected output by eye. On the page, Copy input copies a test's input, and pasting your output into the box under it and pressing Check compares it the VPL way.
  2. From a file. Save the test input as in.txt in the same folder and run ./a1 < in.txt. The < feeds the file to scanf, which is exactly what VPL does.
  3. All five at once. Press Download test script on the card. It saves s0-a1-tests.sh (to Downloads; move it into your folder). Then run sh s0-a1-tests.sh a1.c. It compiles your file with cc -Wall -Wextra, runs all 5 tests, and compares the VPL way.

What the script prints (real output, fix-it 9's program before and after the fix):

Test 1: FAIL
  input:
    5
  expected:
    25
  your output:
    Number please: 25
… Tests 2–5 the same …
0 / 5 tests passed
Test 1: PASS
Test 2: PASS
Test 3: PASS
Test 4: PASS
Test 5: PASS
5 / 5 tests passed

A FAIL shows the input, what was expected and what your program printed, so the difference is usually visible at once. If a program crashes or loops forever, the script stops it after 3 seconds and says so.

Before you press Evaluate
  1. Nothing is printed before the first scanf: no prompts.
  2. Every word your program prints appears in the statement's Output description; all debug prints are gone.
  3. It compiles with -Wall -Wextra and no warnings.
  4. You ran the sample and at least one edge input you made up (0, a boundary value, equal values), and checked those outputs against the statement by hand.

6 · Fix-it drill: ten broken programs

Each program has one bug. Read the code and the symptom, and find the bug before opening the box. Then type the program, fix it, and confirm the corrected output. In the symptoms, the input you type is in colour and the lines after it are what the program prints. Eight of the ten compile without a single warning: the compiler only checks grammar, never your logic. The last two are the ones that cost the most in lab evaluations, because the program is correct and still scores zero.

Fix-it 1 · The average that lost its decimals

#include <stdio.h>

int main(void) {
    int a, b, c;
    double avg;
    scanf("%d %d %d", &a, &b, &c);
    avg = (a + b + c) / 3;
    printf("Average: %.2f\n", avg);
    return 0;
}
Symptom (no warnings)
1 2 2
Average: 1.00
Show the bug and the fix

(a + b + c) / 3 is int / int = 1, and only then stored as 1.00. Fix: (a + b + c) / 3.0. Then:

1 2 2
Average: 1.67

Fix-it 2 · Water boils at 132 degrees

#include <stdio.h>

int main(void) {
    double c, f;
    scanf("%lf", &c);
    f = 9 / 5 * c + 32;
    printf("Fahrenheit: %.1f\n", f);
    return 0;
}
Symptom (no warnings)
100
Fahrenheit: 132.0
Show the bug and the fix

9 / 5 is evaluated first, as int / int = 1, so the formula became 1 * c + 32. The fact that c is a double comes too late. Fix: 9.0 / 5 * c + 32 (Lecture 2's own example writes 9.0 for exactly this reason).

100
Fahrenheit: 212.0

Fix-it 3 · The swap that copies

#include <stdio.h>

int main(void) {
    int a, b;
    scanf("%d %d", &a, &b);
    a = b;
    b = a;
    printf("a = %d, b = %d\n", a, b);
    return 0;
}
Symptom (no warnings)
3 8
a = 8, b = 8
Show the bug and the fix

After a = b; the old value of a is gone, so b = a; just copies 8 back. Fix: park it first: int temp = a; a = b; b = temp;

3 8
a = 8, b = 3

Fix-it 4 · 125 seconds is 5 minutes?

#include <stdio.h>

int main(void) {
    int total, min, sec;
    scanf("%d", &total);
    min = total % 60;
    sec = total / 60;
    printf("%d min %d s\n", min, sec);
    return 0;
}
Symptom (no warnings)
125
5 min 2 s
Show the bug and the fix

/ and % are swapped. Whole minutes = total / 60 (how many 60s fit); leftover seconds = total % 60 (what's left over).

125
2 min 5 s

Fix-it 5 · The section letter it never reads

#include <stdio.h>

int main(void) {
    int roll;
    char section;
    scanf("%d", &roll);
    scanf("%c", &section);
    printf("Roll %d is in section [%c]\n", roll, section);
    return 0;
}
Symptom (no warnings): it prints before you can type the letter
42
Roll 42 is in section [
]
Show the bug and the fix

Typing 42 and pressing Enter leaves the Enter character ('\n') waiting. %d stops before it, and %c takes it, which is why the brackets have a line break inside. VPL's input file has the same line break after 42, so the same thing happens there. Fix: scanf(" %c", &section);. The space means "skip any whitespace first".

42
B
Roll 42 is in section [B]

Fix-it 6 · The sum that ignores the second number

#include <stdio.h>

int main(void) {
    int a, b;
    scanf("%d,%d", &a, &b);
    printf("Sum: %d\n", a + b);
    return 0;
}
Symptom (no warnings; the wrong number can differ run to run)
3 4
Sum: 4
Show the bug and the fix

The format says "%d,%d", so scanf demands a literal comma after the first number. It saw a space, gave up, and b was never filled (garbage). Fix: make the format match the input: "%d %d". In a lab evaluation the input format is fixed by the statement, so the format string has to follow it.

3 4
Sum: 7

Fix-it 7 · Seven is even

#include <stdio.h>

int main(void) {
    int n;
    scanf("%d", &n);
    if (n % 2 == 0);
        printf("%d is even\n", n);
    return 0;
}
Symptom
prog.c:6:20: warning: if statement has empty body [-Wempty-body]
    6 |     if (n % 2 == 0);
      |                    ^
prog.c:6:20: note: put the semicolon on a separate line to silence this warning
1 warning generated.
7
7 is even
Show the bug and the fix

The ; right after if (…) is the if's body (an empty statement). The indented printf is just the next line and always runs. Indentation means nothing to C. Fix: delete that ;. Now 7 prints nothing (add an else for "odd", which is Stage 1 material).

Fix-it 8 · The area computed too early

#include <stdio.h>

int main(void) {
    int length, width;
    int area = length * width;
    scanf("%d %d", &length, &width);
    printf("Area: %d\n", area);
    return 0;
}
Symptom
prog.c:5:16: warning: variable 'length' is uninitialized when used here [-Wuninitialized]
    5 |     int area = length * width;
      |                ^~~~~~
prog.c:4:15: note: initialize the variable 'length' to silence this warning
4 5
Area: -216661928
Show the bug and the fix

int area = length * width; runs once, at that line, before the numbers are read. It is not a formula that updates itself later. Fix: move the line below the scanf.

4 5
Area: 20

Fix-it 9 · The prompt that fails every test

The task: read an integer n, print n squared. Nothing else.

#include <stdio.h>

int main(void) {
    int n;
    printf("Number please: ");
    scanf("%d", &n);
    printf("%d\n", n * n);
    return 0;
}
Symptom (no warnings; the test script's real output)
% sh s0-fix9-tests.sh fix9.c
Test 1: FAIL
  input:
    5
  expected:
    25
  your output:
    Number please: 25
Test 2: FAIL
  input:
    0
  expected:
    0
  your output:
    Number please: 0
… Tests 3–5 fail the same way …
0 / 5 tests passed
Show the bug and the fix

The squaring is right. The output is not: VPL reads it as the tokens Number, please:, 25, and the expected output is the single token 25. Every test fails, so the mark is 0 for a correct program. Fix: delete the prompt line. VPL types the input for you; nobody needs to be asked. Any prompt does the same damage, whatever its wording ("Enter a number", "n =", "Input")

% sh s0-fix9-tests.sh fix9.c
Test 1: PASS
Test 2: PASS
Test 3: PASS
Test 4: PASS
Test 5: PASS
5 / 5 tests passed

Fix-it 10 · The debug print left behind

The task: read three marks, print their average to 2 decimals. While writing it, a line was added to check the sum.

#include <stdio.h>

int main(void) {
    int a, b, c, sum;
    scanf("%d %d %d", &a, &b, &c);
    sum = a + b + c;
    printf("sum = %d\n", sum);          /* just checking */
    printf("%.2f\n", sum / 3.0);
    return 0;
}
Symptom (no warnings): expected 18.33
17 18 20
sum = 55
18.33
Show the bug and the fix

The answer line is right, but VPL compares everything printed: sum = 55 18.33 is four tokens, the expected output is one. All five tests fail. Fix: delete the checking line (or turn it into a comment) before you press Evaluate. Debug prints are a good habit while writing; removing them is the last step, every time.

17 18 20
18.33

Rung A · Warm-up

5–10 minutes each, 3–8 lines of code. Trains: one scanf, one calculation, one silent printf of exactly the output asked for. Write each from a blank file without looking anything up; if you must look something up, find it in the kit table above, not in the solution. Then run the 5 tests (how).

A1 · Rectangle area and perimeter

Rung A 5 min · Pattern: read → compute → print

Problem

Read the length and width of a rectangle (whole centimetres). Print its area and its perimeter.

Input Two integers on one line: length width (0 or more).

Output Two integers separated by a space: the area, then the perimeter.

Test 1 · sample
7 3
21 20
Test 2
0 5
0 10
Test 3
1 1
1 4
Test 4
0 0
0 0
Test 5
12 5
60 34
Stuck? First move

Two int variables, length and width. One scanf("%d %d", …) with two &s, and no printf before it. You don't need extra variables for the answers: printf can print an expression directly.

Plan in plain words
  1. Read both numbers (silently).
  2. Print length × width, a space, 2 × (length + width), then a newline.
Full solution (clang -Wall -Wextra: no warnings · passes all 5 tests)
#include <stdio.h>

int main(void) {
    int length, width;
    scanf("%d %d", &length, &width);    /* no prompt: VPL types the input */

    printf("%d %d\n", length * width, 2 * (length + width));
    return 0;
}
Classic trap

Printing Area: 21. The statement asks for two numbers, so Area: is an extra token and every test fails. Labels belong in your program only when the Output line names them.

A2 · Kilograms to pounds

Rung A 5 min · Pattern: real-number input and output

Problem

Read a mass in kilograms (may have decimals). Print its value in pounds, to 2 decimal places. 1 kg = 2.20462 lb.

Input One real number: the mass in kg (0 or more).

Output One real number with exactly 2 decimals: the mass in lb.

Test 1 · sample
70
154.32
Test 2
0.5
1.10
Test 3
0
0.00
Test 4
2.5
5.51
Test 5
100
220.46
Stuck? First move

"May have decimals" → double kg; and read it with %lf. Print with %.2f.

Plan in plain words
  1. Read kg.
  2. lb = kg × 2.20462.
  3. Print lb with 2 decimals.
Full solution (clang -Wall -Wextra: no warnings · passes all 5 tests)
#include <stdio.h>

int main(void) {
    double kg;
    scanf("%lf", &kg);              /* double needs %lf in scanf */

    printf("%.2f\n", kg * 2.20462);
    return 0;
}
Classic trap

scanf("%f", &kg) with a double: a warning, then garbage (decoder 7). And %f without .2 prints 154.323400: VPL compares 154.323400 with 154.32 as different tokens.

A3 · Average of three marks

Rung A 5 min · Pattern: integer input, real result

Problem

Read three whole-number marks. Print their average to 2 decimal places.

Input Three integers on one line.

Output One real number with exactly 2 decimals.

Test 1 · sample
17 18 20
18.33
Test 2
1 2 2
1.67
Test 3
0 0 0
0.00
Test 4
100 100 99
99.67
Test 5
1 1 2
1.33
Stuck? First move

Three ints in, one double out. The whole problem is one line: make sure the division is real division.

Plan in plain words
  1. Read a, b, c.
  2. avg = (a + b + c) divided by 3, as real division.
  3. Print with 2 decimals.
Full solution (clang -Wall -Wextra: no warnings · passes all 5 tests)
#include <stdio.h>

int main(void) {
    int a, b, c;
    double avg;
    scanf("%d %d %d", &a, &b, &c);

    avg = (a + b + c) / 3.0;        /* 3.0, not 3: keeps the fraction */
    printf("%.2f\n", avg);
    return 0;
}
Classic trap

/ 3 prints 18.00, 1.00, 99.00 and 1.00 for Tests 1, 2, 4 and 5: four failed tests out of five, −56 %. Only Test 3 (all zeros) would pass, which is why one passing test proves little.

A4 · Swap two numbers

Rung A 5 min · Pattern: temporary variable

Problem

Read two integers into a and b. Print them, then swap the variables' contents (not just the print order) and print them again.

Input Two integers a b, on one line or two.

Output Line 1: a b before the swap. Line 2: a b after the swap.

Test 1 · sample
3 8
3 8
8 3
Test 2
5 5
5 5
5 5
Test 3
-2 7
-2 7
7 -2
Test 4
0 0
0 0
0 0
Test 5
100
-100
100 -100
-100 100
Stuck? First move

Picture two full glasses: you need a third, empty one. Declare int temp;.

Plan in plain words
  1. Read a, b; print them.
  2. temp gets a.
  3. a gets b.
  4. b gets temp.
  5. Print a, b again.
Full solution (clang -Wall -Wextra: no warnings · passes all 5 tests)
#include <stdio.h>

int main(void) {
    int a, b, temp;
    scanf("%d %d", &a, &b);
    printf("%d %d\n", a, b);

    temp = a;       /* park a's value */
    a = b;          /* a takes b's value */
    b = temp;       /* b takes the parked value */

    printf("%d %d\n", a, b);
    return 0;
}
Classic trap

a = b; b = a; (fix-it 3) prints 8 8 on line 2 and fails Tests 1, 3 and 5. Tests 2 and 4 pass anyway because both values are equal, the kind of test that hides a bug.

Rung A+ · Input patterns

10 minutes each, 5–10 lines. Trains the two input/output facts that every lab evaluation relies on: scanf doesn't care how the input is split into lines, and the output must be the exact words the statement names.

A+1 · Count the wheels

Rung A+ 10 min · Pattern: one scanf, any line layout

Problem

A car park counts bicycles (2 wheels), cars (4 wheels) and trucks (6 wheels). Read the three counts and print the total number of wheels.

Input Three integers, 0 or more: bicycles, cars, trucks. They may be on one line, on three lines, or split any other way.

Output One integer: the total number of wheels.

Test 1 · sample
2 3 1
22
Test 2
0
0
0
0
Test 3
1
1
1
12
Test 4
5 0
2
22
Test 5
10
20 30
280
Stuck? First move

Write scanf("%d %d %d", &bikes, &cars, &trucks); exactly as if everything were on one line. %d skips spaces and line breaks before each number (section 3), so the same line handles all five layouts.

Plan in plain words
  1. Read the three counts with one scanf.
  2. Print 2 × bicycles + 4 × cars + 6 × trucks.
Full solution (clang -Wall -Wextra: no warnings · passes all 5 tests)
#include <stdio.h>

int main(void) {
    int bikes, cars, trucks;
    scanf("%d %d %d", &bikes, &cars, &trucks);   /* works for any line layout */

    printf("%d\n", 2 * bikes + 4 * cars + 6 * trucks);
    return 0;
}
Classic trap

Writing the format to "match" the sample's look, e.g. "%d\n%d\n%d" or "%d,%d,%d". The first happens to work (in a format, \n just means "skip whitespace", the same as a space); the comma version stops reading at the first space or line break, leaves the other variables as garbage, and fails all five tests. Spaces between the %ds are all you ever need.

A+2 · Pack into boxes

Rung A+ 10 min · Pattern: exact output phrase · / and %

Problem

A shop packs n items into boxes that hold k items each. Only full boxes are sealed. Print how many boxes are sealed and how many items are left over, in exactly this form: BOXES b LEFT r.

Input Two integers on one line: n k, with n ≥ 0 and k ≥ 1.

Output The word BOXES, the number of full boxes, the word LEFT, the number of items left over, separated by single spaces.

Test 1 · sample
17 5
BOXES 3 LEFT 2
Test 2
0 4
BOXES 0 LEFT 0
Test 3
3 5
BOXES 0 LEFT 3
Test 4
20 5
BOXES 4 LEFT 0
Test 5
7 1
BOXES 7 LEFT 0
Stuck? First move

The numbers are one / and one %. The real work is copying the output phrase into the format string character for character: "BOXES %d LEFT %d\n".

Plan in plain words
  1. Read n and k.
  2. Full boxes = n ÷ k (whole); left over = n mod k.
  3. Print the phrase with both numbers in place.
Full solution (clang -Wall -Wextra: no warnings · passes all 5 tests)
#include <stdio.h>

int main(void) {
    int n, k;
    scanf("%d %d", &n, &k);

    printf("BOXES %d LEFT %d\n", n / k, n % k);   /* words copied from the statement */
    return 0;
}
Classic trap

Near-misses that fail every test: Boxes: 3 Left: 2 (Boxes: with its colon is a different token from BOXES), BOXES 3 LEFT OVER 2 (an extra word), BOX 3 LEFT 2 (a different word). What VPL forgives: letter case (boxes 3 left 2 passes) and spacing (two spaces, or a line break between the parts, still passes).

Rung B · VPL level

15–20 minutes each, 5–12 lines. These are /-and-% problems with no if and no loops. The real lab evaluations (the bank) start at if/else, which is Stage 1. Inside those programs, though, are exactly these arithmetic lines: splitting into units, peeling digits, converting and rounding. This rung trains those lines in the same format the evals use (silent input, exact output, 5 tests), so that in Stage 1 the only new thing is the decision.

B1 · Seconds to hours, minutes, seconds

Rung B VPL format 15 min · Family: arithmetic (no if/else) · Pattern: split into units with / and %

Problem

Read a whole number of seconds. Print it as hours, minutes and seconds, then in clock format hh:mm:ss with two digits each. Hours may exceed 23.

Input One integer, 0 or more: the total seconds.

Output Line 1: three integers h m s. Line 2: the same time as hh:mm:ss, each part at least 2 digits.

Test 1 · sample
3725
1 2 5
01:02:05
Test 2
59
0 0 59
00:00:59
Test 3
0
0 0 0
00:00:00
Test 4
3600
1 0 0
01:00:00
Test 5
90061
25 1 1
25:01:01
Stuck? First move

Variables: total, h, m, s. Do it by hand for 3725 first: how many whole 3600s fit? What's left over? How many whole 60s fit in that? Each question is one / or %.

Plan in plain words
  1. Read total.
  2. h = whole hours in total.
  3. Leftover after hours = total mod 3600; m = whole minutes in the leftover.
  4. s = total mod 60.
  5. Print twice: plain, then with 2-digit padding.
Full solution (clang -Wall -Wextra: no warnings · passes all 5 tests)
#include <stdio.h>

int main(void) {
    int total, h, m, s;
    scanf("%d", &total);

    h = total / 3600;               /* whole hours */
    m = (total % 3600) / 60;        /* what's left after hours, in whole minutes */
    s = total % 60;                 /* what's left after whole minutes */

    printf("%d %d %d\n", h, m, s);
    printf("%02d:%02d:%02d\n", h, m, s);
    return 0;
}
Classic trap

m = total / 60; gives 62 for 3725: the total minutes, including the ones already counted as an hour. You need the minutes left after taking the hours out. Tests 1, 4 and 5 catch it. And %d instead of %02d on line 2 prints 1:2:5, which is a different token from 01:02:05.

B2 · Swap the first and last digits

Rung B VPL format 20 min · Family: arithmetic (no if/else) · Pattern: digit extraction → rebuild

Problem

Read a 4-digit number. Print the number with its first and last digits swapped, always as 4 digits (keep leading zeros).

Input One integer from 1000 to 9999.

Output One 4-digit number.

Test 1 · sample
1234
4231
Test 2
1000
0001
Test 3
5005
5005
Test 4
1230
0231
Test 5
9871
1879
Stuck? First move

Split 1234 into three pieces: first (1), middle (23), last (4). Work out which / and % give each, using 1234 on paper. Then glue them back in the new order.

Plan in plain words
  1. first = number divided by 1000.
  2. last = number mod 10.
  3. middle = drop the last digit, then keep the last two of what's left.
  4. result = last × 1000 + middle × 10 + first.
  5. Print with 4-digit zero padding (so 1 shows as 0001).
Full solution (clang -Wall -Wextra: no warnings · passes all 5 tests)
#include <stdio.h>

int main(void) {
    int n, first, last, middle, result;
    scanf("%d", &n);

    first = n / 1000;               /* 1234 / 1000 = 1 */
    last = n % 10;                  /* 1234 % 10   = 4 */
    middle = (n / 10) % 100;        /* 123 % 100   = 23 */

    result = last * 1000 + middle * 10 + first;
    printf("%04d\n", result);       /* %04d keeps leading zeros */
    return 0;
}
Classic trap

%d prints Test 2 as 1 and Test 4 as 231. The values are right; whether the zeros show is only a printing decision (%04d), but VPL compares what is printed, so both tests fail.

B3 · Height in centimetres to feet and inches

Rung B VPL format 15 min · Family: arithmetic (no if/else) · Pattern: real → rounded int → split

Problem

Read a height in cm (may have decimals). Convert to inches (1 in = 2.54 cm), rounded to the nearest inch, then print it as feet and inches (12 in = 1 ft).

Input One real number, 0 or more: the height in cm.

Output Two integers: feet, then the remaining inches (0–11).

Test 1 · sample
170
5 7
Test 2
152.4
5 0
Test 3
0
0 0
Test 4
182
6 0
Test 5
100
3 3
Stuck? First move

Two stages with a type change in the middle: a double for the cm, an int for the rounded inches. Once it's an int, it's B1 again with 12 instead of 60.

Plan in plain words
  1. Read cm.
  2. inches = cm ÷ 2.54, rounded to the nearest whole number.
  3. feet = inches ÷ 12 (whole); rest = inches mod 12.
  4. Print feet and rest.
Full solution (clang -Wall -Wextra: no warnings · passes all 5 tests)
#include <stdio.h>

int main(void) {
    double cm;
    int inches;
    scanf("%lf", &cm);

    inches = (int)(cm / 2.54 + 0.5);    /* round to the nearest inch */
    printf("%d %d\n", inches / 12, inches % 12);
    return 0;
}
Classic trap

(int)(cm / 2.54) chops: 170 cm = 66.93 in becomes 66 → 5 6, and 182 cm = 71.65 in becomes 71 → 5 11. Rounding is + 0.5 then the cast (see the division table). Tests 1 and 4 catch the chop.

B4 · What time will it be?

Rung B VPL format 20 min · Family: arithmetic (no if/else) · Pattern: convert to one unit → wrap with %

Problem

Read a 24-hour time as two numbers hh mm, then a number of minutes to add (0 or more, may be more than a day). Print the new time as hh:mm.

Input Line 1: two integers hh mm (0–23, 0–59). Line 2: one integer, the minutes to add.

Output The new time as hh:mm, each part 2 digits.

Test 1 · sample
22 45
90
00:15
Test 2
9 5
1500
10:05
Test 3
23 59
1
00:00
Test 4
0 0
0
00:00
Test 5
12 30
2880
12:30
Stuck? First move

Don't add hours to hours and minutes to minutes (you'd have to handle carries). Turn the time into minutes since midnight, one number, add, then turn it back.

Plan in plain words
  1. total = h × 60 + m + minutes to add.
  2. A day has 1440 minutes: keep only total mod 1440.
  3. New hour = total ÷ 60; new minute = total mod 60.
  4. Print both with 2 digits.
Full solution (clang -Wall -Wextra: no warnings · passes all 5 tests)
#include <stdio.h>

int main(void) {
    int h, m, add, total;
    scanf("%d %d %d", &h, &m, &add);   /* the line break before add doesn't matter */

    total = h * 60 + m + add;       /* everything in minutes since midnight */
    total = total % (24 * 60);      /* 1440 minutes in a day: wrap past midnight */

    printf("%02d:%02d\n", total / 60, total % 60);
    return 0;
}
Classic trap

Forgetting the wrap: without % 1440, Test 1 prints 24:15 and Test 5 prints 60:30. Tests 1, 2, 3 and 5 all cross midnight on purpose, because boundaries are where hidden tests look.

Rung C · Beyond the eval (optional)

25–40 minutes each. These are the old "above the sheet" problems: the same arithmetic, but now the program must survive bad input and numbers that don't fit, so they are longer than any eval program at this level. Do them after B, if time allows; they build fluency for the end-semester lab exam. One if form is needed: if (bad) { printf("INVALID\n"); return 0; }, which prints the error word and stops the program there.

C1 · Shift length, overnight included

Rung C 30 min · Pattern: validated input → one unit → wrap-around difference

Problem

Read a start time and an end time, each written as hh:mm (24-hour, colon included). Print the duration in hours and minutes. If the end is earlier than the start, the shift ran past midnight. If either time is not in hh:mm form, print INVALID FORMAT. If the form is right but an hour is outside 0–23 or a minute outside 0–59, print INVALID TIME.

Input Two times on one line: start end, e.g. 09:15 17:40.

Output Two integers hours minutes, or INVALID FORMAT, or INVALID TIME.

Test 1 · sample
09:15 17:40
8 25
Test 2
22:30 06:15
7 45
Test 3
9.30 10:00
INVALID FORMAT
Test 4
12:75 14:00
INVALID TIME
Test 5
08:00 08:00
0 0
Stuck? First move

Reading: scanf("%d:%d", &h1, &m1). The colon in the format makes scanf demand a colon. It returns how many numbers it filled, so != 2 means the format was wrong. Then it's B4 in reverse: both times become minutes since midnight.

Plan in plain words
  1. Read start; if fewer than 2 numbers were read, print INVALID FORMAT and stop. Same for end.
  2. If any hour or minute is out of range, print INVALID TIME and stop.
  3. Convert both to minutes since midnight.
  4. diff = end − start; if that's negative, add a day (1440). One expression does both: (end − start + 1440) mod 1440.
  5. Print diff as hours and minutes.
Full solution (clang -Wall -Wextra: no warnings · passes all 5 tests)
#include <stdio.h>

int main(void) {
    int h1, m1, h2, m2, start, end, diff;

    if (scanf("%d:%d", &h1, &m1) != 2 || scanf("%d:%d", &h2, &m2) != 2) {
        printf("INVALID FORMAT\n");
        return 0;                   /* stop: the error is the whole output */
    }
    if (h1 < 0 || h1 > 23 || m1 < 0 || m1 > 59 ||
        h2 < 0 || h2 > 23 || m2 < 0 || m2 > 59) {
        printf("INVALID TIME\n");
        return 0;
    }

    start = h1 * 60 + m1;
    end = h2 * 60 + m2;
    diff = (end - start + 1440) % 1440;     /* +1440 handles shifts past midnight */

    printf("%d %d\n", diff / 60, diff % 60);
    return 0;
}
Unpack: why (end - start + 1440) % 1440?

22:30 → 06:15 gives end − start = 375 − 1350 = −975. Adding a day: −975 + 1440 = 465 = 7 h 45 min. If the difference was already positive, adding 1440 then % 1440 removes it again. Adding first also keeps % away from negatives (−7 % 2 is −1 in C).

The || also does a small favour: if the first scanf already failed, C doesn't run the second one at all.

Classic trap

Checking only the hours: 12:75 (Test 4) would be accepted as 13:15 and print 1 45. Validate every number you read.

C2 · Your age in seconds: overflow

Rung C 25 min · Pattern: choose a type big enough · validate

Problem

Read an age in whole years. Print the approximate age in seconds, using 365-day years. If the input is not a whole number, or is outside 0–150, print INVALID.

Input One value: the age in years.

Output One integer (the seconds), or INVALID.

Test 1 · sample
20
630720000
Test 2
70
2207520000
Test 3
150
4730400000
Test 4
-3
INVALID
Test 5
abc
INVALID
Stuck? First move

Estimate before coding: one year is 365 × 24 × 60 × 60 = 31,536,000 s. Times 70 is about 2.2 billion, but an int tops out at 2,147,483,647. So the answer needs long long, printed with %lld.

Plan in plain words
  1. Read years; if scanf didn't read 1 number, or it's out of 0–150, print INVALID and stop.
  2. Convert years to long long before multiplying, then multiply by 365, 24, 60, 60.
  3. Print with %lld.
Full solution (clang -Wall -Wextra: no warnings · passes all 5 tests)
#include <stdio.h>

int main(void) {
    int years;
    long long seconds;

    if (scanf("%d", &years) != 1 || years < 0 || years > 150) {
        printf("INVALID\n");
        return 0;
    }

    seconds = (long long)years * 365 * 24 * 60 * 60;   /* cast FIRST */
    printf("%lld\n", seconds);
    return 0;
}

Here is the same thing with plain int everywhere. It compiles with no warning:

68
2144448000
70
-2087447296

68 still fits; 69 and up wrap around to nonsense. A negative age in seconds is the giveaway, but a wrapped value can just as easily look plausible. Tests 2 and 3 are there to catch it.

Classic trap

long long seconds = years * 365 * 24 * 60 * 60; still overflows: the right side is all int and is computed (and wrapped) before being stored. That's the division trap again: the type of the box doesn't change how the right side is computed. Cast one operand first, as the solution does.

C3 · Split the bill to the paisa

Rung C 40 min · Pattern: money as integer paise · ceiling division · validate

Problem

Read a bill in rupees (up to 2 decimals) and the number of people. Each person pays the same amount, in whole paise, rounded up so the bill is always covered. Print what each pays, then the total collected and the extra in paise. If the bill is negative or not a number, or there are fewer than 1 people, print INVALID.

Input Two values on one line: bill people.

Output Line 1: each person's share in rupees, 2 decimals. Line 2: the total collected in rupees (2 decimals), a space, the extra in paise (an integer). Or just INVALID.

Test 1 · sample
1000 3
333.34
1000.02 2
Test 2
19.99 1
19.99
19.99 0
Test 3
100 0
INVALID
Test 4
0.10 3
0.04
0.12 2
Test 5
-5 2
INVALID
Stuck? First move

Work in paise, as whole numbers, from the moment you've read the bill: long long paise. Doubles can't hold 19.99 exactly, so any rounding has to happen once, on purpose, at the start. Then it's integer arithmetic only.

Plan in plain words
  1. Read the bill (double) and people (int); reject bad values with INVALID.
  2. paise = bill × 100, rounded to the nearest whole number.
  3. each = paise ÷ people, rounded up.
  4. collected = each × people.
  5. Print rupees = value ÷ 100 and paise = value mod 100 (2 digits).
Full solution (clang -Wall -Wextra: no warnings · passes all 5 tests)
#include <stdio.h>

int main(void) {
    double bill;
    int people;
    long long paise, each, collected;

    if (scanf("%lf %d", &bill, &people) != 2 || bill < 0 || people < 1) {
        printf("INVALID\n");
        return 0;
    }

    paise = (long long)(bill * 100 + 0.5);      /* round to the nearest paisa */
    each = (paise + people - 1) / people;       /* divide, rounding UP */
    collected = each * people;

    printf("%lld.%02lld\n", each / 100, each % 100);
    printf("%lld.%02lld %lld\n", collected / 100, collected % 100, collected - paise);
    return 0;
}
Unpack: why does (paise + people - 1) / people round up?

Integer division rounds down. Adding people − 1 first pushes any non-zero remainder over the next multiple: 100000 / 3 → (100000 + 2) / 3 = 33334. If it divides exactly (99 / 3), the +2 isn't enough to reach the next one: 101 / 3 = 33.

Classic trap

Chopping instead of rounding when converting to paise. Real run of (int)(bill * 100):

19.99
1998

19.99 is stored as 19.98999…, so ×100 gives 1998.999… and the cast chops it to 1998. One paisa lost, silently, and Test 2 fails. + 0.5 before the cast fixes it.

Practising with an AI? Ask it well

"I'm a C beginner. Here's my program and the exact compiler message: [paste both]. Explain what the message means in plain words and which line causes it. Don't rewrite my program."

"Give me three new C problems at the level of 'seconds to h:m:s' that use only scanf, printf, / and %. No loops, no if. Write them like a Moodle VPL lab evaluation: an input format, an exact output format, and 5 test cases (input and expected output) including edge cases like 0. No prompts in the expected output, and no solutions."

Self-test before moving on

All four ticked → Stage 1. If B1 or B4 needed the plan, redo them tomorrow from blank; second attempts are usually twice as fast. Rung C is optional and doesn't gate Stage 1.