Fig. 1 shows part of a program used to create seat labels for a small theatre. There are 3 rows and 4 seats in each row. The outer loop controls the row num...

Assessment: Computer Science 4CP0 | Paper 2 Mock 01 | Written Paper 2 Subject: Computer Science - 4CP0

Question 1 Report

Fig. 1 shows part of a program used to create seat labels for a small theatre. There are 3 rows and 4 seats in each row. The outer loop controls the row number and the inner loop controls the seat number. For each seat, the program displays a label such as R2-S3. A programmer has removed two words from the code and wants to check the sequence of labels before saving the source file. The diagram is a structured representation of nested iteration.

FOR row = 1 TO 3FOR seat = 1 TO 4DISPLAY "R", row, "-S", seatEND FOREND FOR© EAGLE BEACON GLOBAL

Fig. 1: nested loops for theatre-seat labels

(a) Identify the total number of labels displayed when the program is correct. [2]
(b) Write the two labels displayed immediately after R1-S4. [2]
(c) Use the code in Fig. 1 to complete a trace table for row 3 by giving the values of seat and the label displayed for all four inner-loop repetitions. [4]

Answer Details

(a) There are 3 rows with 4 seats each:

\[3 \times 4 = 12\]

Therefore, 12 labels are displayed [2]. The inner loop completes four times for each outer-loop row.

(b) After R1-S4, the inner loop has finished for row 1. The next two labels are R2-S1 [1] and R2-S2 [1]. [2]

(c) When row = 3, the inner loop changes seat from 1 to 4:

seatLabel displayed
1R3-S1
2R3-S2
3R3-S3
4R3-S4

Each correct seat value and matching label gains [1]. [4]

Download The App On Google Playstore

Everything you need to excel in your exams

Green Bridge CBT Mobile App
Personalized AI Learning Chat Assistant
200,000+ Exam Questions Across IGCSE, JAMB, WAEC & NECO
Over 3,900 Lesson Notes
Offline Support - Learn Anytime, Anywhere
Green Bridge Timetable
Literature Summaries & Potential Questions
Track Your Performance & Progress
In-depth Explanations for Comprehensive Learning