⏱️
15 questions · 22 marks · 40 minutes. Negative marking on MCQ only: −1/3 mark for a wrong 1-mark MCQ, −2/3 for a wrong 2-mark MCQ. No negative marking for MSQ or NAT; MSQ has no partial credit.
Q1MCQ1 markToolchain
Which converts C source code into an executable?
- (A) main
- (B) the processor
- (C) printf
- (D) the compiler
Q2MCQ1 markOutput
What does this print?
printf("ab\n");
printf("c\td\n");
- (A)
ab\ncd - (B)
ab cd - (C)
abthenc, tab,don the next line - (D)
abc d
Q3NAT1 markEscape sequences
How many characters does "\"Hi\"\n" contain?
Numerical answer: ________
Q4MCQ2 marksComments
What does this print?
printf("A"); // printf("B");
/* printf("C"); */ printf("D");
printf("// E\n");
- (A)
AD// E - (B)
ABCD E - (C)
AD E - (D)
AD
Q5MCQ2 marksVariables
What does this print?
int a = 5;
int b = a + 1;
a = b + a;
b = a + b;
printf("%d %d\n", a, b);
- (A)
11 17 - (B)
6 11 - (C)
5 6 - (D)
11 12
Q6NAT1 markAddresses
Five ints are stored one after another starting at address 1200 (4 bytes each). What is the address of the last byte of the fifth int?
Numerical answer: ________
Q7MSQ1 markIdentifiers
Which are valid names?
- (A)
9lives - (B)
sum2 - (C)
my_var - (D)
int
Q8NAT1 markBits
How many bits are needed so that 300 different values each get their own pattern?
Numerical answer: ________
Q9NAT2 marksLogs
What is log₂ (2^20^ / 2^5^) + log₂ 1?
Numerical answer: ________
Q10MCQ1 markCeiling
⌈7/2⌉ + ⌊7/2⌋ equals:
- (A) 3.5
- (B) 6
- (C) 8
- (D) 7
Q11NAT2 marksGuessing
Guessing a secret number from 1 to 500 by always picking the middle, what is the worst-case number of guesses?
Numerical answer: ________
Q12NAT1 markSeries
What is 1 + 2 + … + 30?
Numerical answer: ________
Q13NAT2 marksSeries
What is 1 + 2 + 4 + … + 1024?
Numerical answer: ________
Q14MCQ2 marksCounting
Every pair of 12 cities is joined by exactly one road. How many roads?
- (A) 144
- (B) 132
- (C) 66
- (D) 24
Q15MSQ2 marksCounting
Which are correct?
- (A) A set of 4 items has 16 subsets
- (B) 4! = 4 + 3 + 2 + 1
- (C) 0! = 1
- (D) 5C2 = 5C3
Answer Vault
Try the questions first. Open when you are ready to check.
Q1 Answer: (D)1 mark
The compiler translates source code into machine code.
- (A) is wrong: main is where running starts.
- (B) is wrong: The processor runs machine code; it does not translate C.
- (C) is wrong: printf prints text.
Re-read: Lesson 0.1.1 — Programs and instructions; source code → compiler → executable; the shape of a first C program (main, printf, return)
Q2 Answer: (C)1 mark
Output
ab
c d
- (A) is wrong: Escape sequences are not printed literally.
- (B) is wrong: The \n starts a new line.
- (D) is wrong: ab ends with a new line.
Re-read: Lesson 0.1.1 — Programs and instructions; source code → compiler → executable; the shape of a first C program (main, printf, return)
Q3 Answer: 51 mark
", H, i, ", new line: 5.
Re-read: Lesson 0.1.1 — Programs and instructions; source code → compiler → executable; the shape of a first C program (main, printf, return)
Q4 Answer: (A)2 marks
Output
AD// E
The // inside quotes is printed.
- (B) is wrong: B and C are inside comments.
- (C) is wrong: The // is part of the string literal and is printed.
- (D) is wrong: The third printf prints "// E".
Re-read: Lesson 0.1.1 — Programs and instructions; source code → compiler → executable; the shape of a first C program (main, printf, return)
Q5 Answer: (A)2 marks
b = 6; a = 6 + 5 = 11; b = 11 + 6 = 17.
Output
11 17
- (B) is wrong: a becomes 11.
- (C) is wrong: Both values change.
- (D) is wrong: b uses the new a = 11.
Re-read: Lesson 0.1.2 — Memory as numbered boxes: bits, bytes, addresses; a variable as a named box
Q6 Answer: 12191 mark
5 × 4 = 20 bytes: 1200 to 1219.
Re-read: Lesson 0.1.2 — Memory as numbered boxes: bits, bytes, addresses; a variable as a named box
Q7 Answer: (B) (C)1 mark
Keywords and leading digits are not allowed.
- (A) is wrong: Starts with a digit.
- (D) is wrong: int is a keyword.
Re-read: Lesson 0.1.2 — Memory as numbered boxes: bits, bytes, addresses; a variable as a named box
Q8 Answer: 91 mark
256 < 300 ≤ 512 = 2⁹: 9.
Re-read: Lesson 0.2.1 — Powers of 2 and logarithms; floor and ceiling
Q9 Answer: 152 marks
log₂ 2^15^ = 15; log₂ 1 = 0: 15.
Re-read: Lesson 0.2.1 — Powers of 2 and logarithms; floor and ceiling
Q10 Answer: (D)1 mark
4 + 3 = 7.
- (A) is wrong: Floor and ceiling give whole numbers.
- (B) is wrong: Uses 3 for both.
- (C) is wrong: Uses 4 for both.
Re-read: Lesson 0.2.1 — Powers of 2 and logarithms; floor and ceiling
Q11 Answer: 92 marks
⌊log₂ 500⌋ + 1 = 8 + 1 = 9 (checked by simulation: 9).
Re-read: Lesson 0.2.1 — Powers of 2 and logarithms; floor and ceiling
Q12 Answer: 4651 mark
30 × 31/2 = 465.
Re-read: Lesson 0.2.2 — Sums of series (1+2+…+n, 1+2+4+…+2ⁿ); basic counting
Q13 Answer: 20472 marks
1024 = 2¹⁰: 2¹¹ − 1 = 2047.
Re-read: Lesson 0.2.2 — Sums of series (1+2+…+n, 1+2+4+…+2ⁿ); basic counting
Q14 Answer: (C)2 marks
12C2 = 12 × 11/2 = 66.
- (A) is wrong: 12² counts each city with itself and each pair twice.
- (B) is wrong: Counts each road twice.
- (D) is wrong: Not a pair count.
Re-read: Lesson 0.2.2 — Sums of series (1+2+…+n, 1+2+4+…+2ⁿ); basic counting
Q15 Answer: (A) (C) (D)2 marks
5C2 = 5C3 = 10; 4! = 24, not 10.
- (B) is wrong: 4! multiplies: 24.
Re-read: Lesson 0.2.2 — Sums of series (1+2+…+n, 1+2+4+…+2ⁿ); basic counting
If you got these wrong, re-read
| Question | Marks | Topic | Re-read |
|---|---|---|---|
| Q1 | 1 | Toolchain | Lesson 0.1.1 |
| Q2 | 1 | Output | Lesson 0.1.1 |
| Q3 | 1 | Escape sequences | Lesson 0.1.1 |
| Q4 | 2 | Comments | Lesson 0.1.1 |
| Q5 | 2 | Variables | Lesson 0.1.2 |
| Q6 | 1 | Addresses | Lesson 0.1.2 |
| Q7 | 1 | Identifiers | Lesson 0.1.2 |
| Q8 | 1 | Bits | Lesson 0.2.1 |
| Q9 | 2 | Logs | Lesson 0.2.1 |
| Q10 | 1 | Ceiling | Lesson 0.2.1 |
| Q11 | 2 | Guessing | Lesson 0.2.1 |
| Q12 | 1 | Series | Lesson 0.2.2 |
| Q13 | 2 | Series | Lesson 0.2.2 |
| Q14 | 2 | Counting | Lesson 0.2.2 |
| Q15 | 2 | Counting | Lesson 0.2.2 |