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.
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?
A
the statements between PROCEDURE and ENDPROCEDURE
B
the list of local variables declared inside it
C
the value that the procedure returns to its caller
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?
A
both BYVAL
B
the first BYREF, the second BYVAL
C
as the return values of a function
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?
A
write a procedure PrintHeader and call it in each place
B
copy the header statements into each of the five places
C
write a function that returns the output of the whole program
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?
A
parameters
B
return values
C
arguments
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?
A
2.67
B
9
C
11
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
A
the loop never ends, as Count is never exactly 10
B
the loop body runs 5 times and then the loop stops
C
the loop body runs 9 times and then the loop stops
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
A
9
B
5
C
14
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?
A
CALL Largest(A, B)
B
Big ← Largest(A, B)
C
Largest(A, B) ← Big
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
A
10
B
6
C
5
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?
A
a count-controlled loop (FOR ... NEXT)
B
a pre-condition loop (WHILE ... ENDWHILE)
C
a post-condition loop (REPEAT ... UNTIL)
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.
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.