Class 3 — Tuesday, September 1
seconds.c.
1 Predict, then run — round 1
Write down what you think each line prints before you run anything.
Add them to hello.c, below the line already there. Recompile with gcc hello.c -o hello, then run ./hello.
Circle every line where your prediction and the output disagree. Those are the only ones worth talking about.
The middle line is the one A1 Part B cannot be done without.
2 Predict, then run — round 2
Same rule: write your prediction down first. These two are shorter than they look, and for each one there are two things to predict — what it prints, and whether it compiles at all.
Put each one inside main, compile, and run it. Read everything gcc prints, including nothing at all — whether the compiler stayed quiet is part of the result here, not a detail.
3 seconds.c — the first three lines
This is the start of A1 Part B. We do the first piece together; the rest is yours.
Make a new file, seconds.c, and give it exactly one number to work from:
Get it to print only the whole hours, like this:
10000 seconds is 2 h
Then stop and compare with the person next to you. If you both got 2, you are ready for the minutes — which is homework.
One number lives at the top. If you find yourself typing 10000 a second time anywhere, that is the thing the assignment is asking you not to do.