Skip to content
Michelle’s Computer
Terminal

Programming fundamentals quiz

Test variables, constants, data types, conditions, loops, arrays, functions, and common programming errors.

syllabus — topic scope & references
  • Choose suitable data types and control structures
  • Trace arrays and accumulators
  • Distinguish syntax errors from logic errors

Cambridge IGCSE 0478 (2026–2028): 8.1, 8.2 Programming concepts; arrays.

IB Computer Science (first assessment 2027): B.2 Programming.

Original practice on shared foundations. Topic-area links do not imply complete syllabus or SL/HL coverage. Not affiliated with or endorsed by Cambridge or the IB.

Related: Algorithms and computational thinking · Boolean logic and truth tables · Databases and SQL

PROGRAMMING FUNDAMENTALS QUIZ
10 questions. Type a, b, or c, then Enter. Explanations follow each answer.
Type review for all worked answers; quiz to restart; topics to switch.
 
Question 1/10: Which data type is most suitable for the number of students in a class?
a) Integer
b) Boolean
c) Character
Type answer a, answer b, or answer c. (A single letter works too.)
review — read all questions & worked answers

Programming fundamentals: questions, answers & explanations

This is the readable reference for the same 10 MCQs. Close this file to continue your quiz, or type quiz to start again.

1. Which data type is most suitable for the number of students in a class?

  1. a) Integer
  2. b) Boolean
  3. c) Character

Answer: a) Integer

A count of students is a whole number, so an integer is suitable. A Boolean has two logical values; a character holds one character.

2. How does a constant differ from a variable?

  1. a) A constant must contain text
  2. b) A constant is intended to retain its assigned value during execution
  3. c) A variable can hold only one digit

Answer: b) A constant is intended to retain its assigned value during execution

A constant represents a value that should not be reassigned. A variable can be updated as a program runs.

3. Which control structure chooses between paths based on a condition?

  1. a) A comment
  2. b) An assignment alone
  3. c) Selection, such as IF...ELSE

Answer: c) Selection, such as IF...ELSE

Selection runs a particular path depending on a Boolean condition. IF...ELSE is one way to express it.

4. How many times can a pre-condition WHILE loop run if its condition is false at the first check?

  1. a) Zero
  2. b) Exactly once
  3. c) At least twice

Answer: a) Zero

A pre-condition loop tests before entering its body. If the condition starts false, the body is skipped.

5. Trace this pseudocode: count ← 0 FOR EACH value IN [4, 8, 2] count ← count + 1 ENDFOR What is count?

  1. a) 14
  2. b) 3
  3. c) 1

Answer: b) 3

The loop increments once for each of three items. It counts items rather than adding their values.

6. Trace this pseudocode: total ← 0 FOR EACH value IN [4, 8, 2] total ← total + value ENDFOR What is total?

  1. a) 3
  2. b) 8
  3. c) 14

Answer: c) 14

This accumulator adds the values: 4 + 8 + 2 = 14. It totals values rather than counting items.

7. The array [4, 7, 9] uses zero-based indexing. What is the value at index 1?

  1. a) 7
  2. b) 4
  3. c) 9

Answer: a) 7

With zero-based indexing, index 0 holds 4, index 1 holds 7, and index 2 holds 9.

8. In this pseudocode, FUNCTION double(n) RETURNS n * 2. What is double(6)?

  1. a) 3
  2. b) 12
  3. c) 36

Answer: b) 12

The function multiplies its input by 2 and returns that result. With n = 6, the return value is 12.

9. Which example is a logic error?

  1. a) A missing closing parenthesis that breaks the language's syntax
  2. b) An unclosed quotation mark in source code
  3. c) A program runs but calculates a rectangle's area using width + height

Answer: c) A program runs but calculates a rectangle's area using width + height

The program follows the language's syntax but uses the wrong method. A rectangle's area should be width × height.

10. A condition must represent either true or false. Which data type matches that purpose?

  1. a) Boolean
  2. b) Real
  3. c) String

Answer: a) Boolean

A Boolean represents a logical true or false value and is used in conditions.

↑ ↓ recall commands · Tab autocomplete · Enter run