AS Level Computer Science chapter 11: Programming MCQs with answers

By Team Megalecture · Updated 4 Nov 2026

32 exam-style questions on Programming, each with the answer and a short explanation. Ten of them are below to try. The chapter test draws ten fresh questions each time and is marked the moment you finish, with your score by topic.

32 questions · 3 topics · 10 per test

Test this chapter freeAll AS Level Computer Science chapters

What chapter 11 covers

Ten Programming questions with answers

Try each one, then open the answer. These ten stay the same; the test draws new ones every time.

1. What is meant by the interface of a procedure?

  1. A
    the statements between PROCEDURE and ENDPROCEDURE
  2. B
    the list of local variables declared inside it
  3. C
    the value that the procedure returns to its caller
  4. D
    its parameters, their types and how each is passed
Show answer

Answer: D. The interface is how the module communicates with the rest of the program: its name, parameters, their types and whether they are BYVAL or BYREF.

2. A procedure Swap must exchange the values of two variables in the calling program. How must its two parameters be passed?

  1. A
    both BYVAL
  2. B
    the first BYREF, the second BYVAL
  3. C
    as the return values of a function
  4. D
    both BYREF
Show answer

Answer: D. Both caller's variables must change, so both parameters must refer to the originals: BYREF. BYVAL would only swap local copies.

3. A program prints the same formatted receipt header in five different places. What is the best approach?

  1. A
    write a procedure PrintHeader and call it in each place
  2. B
    copy the header statements into each of the five places
  3. C
    write a function that returns the output of the whole program
  4. D
    use a separate global constant for each line of the header
Show answer

Answer: A. A procedure is written once and called wherever needed, so the code is shorter and a change is made in one place only.

4. In the statement CALL Swap(X, Y), what are X and Y called?

  1. A
    parameters
  2. B
    return values
  3. C
    arguments
  4. D
    local constants
Show answer

Answer: C. Values given in a call are arguments. The matching names in the procedure header are its parameters.

5. What is the value of the expression 3 + 4 * 2 - 6 / 3?

  1. A
    2.67
  2. B
    9
  3. C
    11
  4. D
    13
Show answer

Answer: B. Multiplication and division first: 4 * 2 = 8 and 6 / 3 = 2. Then 3 + 8 − 2 = 9. Working left to right gives 2.67.

6. What happens when this code is run?
Count ← 1
WHILE Count <> 10 DO
   Count ← Count + 2
ENDWHILE

  1. A
    the loop never ends, as Count is never exactly 10
  2. B
    the loop body runs 5 times and then the loop stops
  3. C
    the loop body runs 9 times and then the loop stops
  4. D
    the loop body is never executed because Count is 1
Show answer

Answer: A. Count takes the odd values 1, 3, 5, 7, 9, 11, ... so it is never equal to 10 and the condition stays TRUE: an infinite loop. Using Count < 10 would fix it.

7. What is output by OUTPUT Largest(4, Largest(9, 2)) + 1?
FUNCTION Largest(P : INTEGER, Q : INTEGER) RETURNS INTEGER
   IF P > Q THEN
      RETURN P
   ELSE
      RETURN Q
   ENDIF
ENDFUNCTION

  1. A
    9
  2. B
    5
  3. C
    14
  4. D
    10
Show answer

Answer: D. The inner call runs first: Largest(9, 2) returns 9. Then Largest(4, 9) returns 9, and 9 + 1 = 10.

8. Largest is a function that returns an INTEGER. Which statement uses it correctly?

  1. A
    CALL Largest(A, B)
  2. B
    Big ← Largest(A, B)
  3. C
    Largest(A, B) ← Big
  4. D
    RETURN Largest
Show answer

Answer: B. A function call is used in an expression and its return value replaces the call, here assigned to Big. CALL is used for procedures.

9. What is output by this code?
Count ← 10
REPEAT
   Count ← Count + 1
UNTIL Count > 5
OUTPUT Count

  1. A
    10
  2. B
    6
  3. C
    5
  4. D
    11
Show answer

Answer: D. A post-condition loop always runs at least once: Count becomes 11, then 11 > 5 is TRUE so the loop stops. A WHILE Count <= 5 loop would not run at all and output 10.

10. A program must keep asking for a password until the correct one is entered, and it must ask at least once. Which loop is most suitable?

  1. A
    a count-controlled loop (FOR ... NEXT)
  2. B
    a pre-condition loop (WHILE ... ENDWHILE)
  3. C
    a post-condition loop (REPEAT ... UNTIL)
  4. D
    a CASE structure with an OTHERWISE clause
Show answer

Answer: C. The number of attempts is unknown and the prompt must happen before the test, so a post-condition loop fits. A FOR loop needs a known count.

Start the chapter testAbout the AS Level Computer Science test

Read the notes for this chapter

Ways to practise this chapter

Programming: questions students ask

How many Programming MCQs are there?

32, each with the answer and a short explanation, across 3 topics: Programming basics, Constructs, Structured programming. Every chapter test draws ten of them, so you can take it many times.

Is the AS Level Computer Science chapter 11 test free?

Yes. The test, the answers and the explanations are free and need no sign-up. Sign in only if you want your scores kept across devices.

How is the chapter test marked?

The moment you press Finish: your score, the right answer and an explanation for every question, and the ones you got wrong saved in My mistakes to retry.

Keep going

← Chapter 10: Data types and structuresChapter 12: Software development →All chaptersStuck? Ask a question