A shop program is written in pseudocode. It accepts the prices of three items and calculates their mean price. The programmer has chosen a high-level langua...

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

Question 1 Report

A shop program is written in pseudocode. It accepts the prices of three items and calculates their mean price. The programmer has chosen a high-level language because the program may later need to be changed for a different shop. Assume that the three input values are 12, 15 and 9, in that order. The program uses an integer loop counter, while the result of the division may contain a fractional part.

total ← 0
FOR item ← 1 TO 3
    INPUT price
    total ← total + price
NEXT item
average ← __________
OUTPUT average

Use the trace table when answering part (b).

itempricetotal after addition
112__________
215__________
39__________

(a) State two advantages of using a high-level language for this program. [2]

(b) Complete the trace table. [3]

(c) Give the most suitable data type for average. [2]

(d) Convert denary 25 to an 8-bit binary value. [2]

(e) State two characteristics of a compiler. [2]

(f) Explain why the pseudocode must be translated before it can be executed by the processor. [2]

(g) Complete the missing assignment statement. [2]

Answer Details

(a) A high-level language is easier for humans to read because it uses meaningful statements, and it is easier to write, maintain and modify [2]. It can also be translated for different processors.

(b)

itempricetotal after addition
11212
21527
3936

The total is an accumulator: each price is added to its current value [3].

(c) average should be a real/float [2], because division can produce a fractional result.

(d) \(25=16+8+1\), so the 8-bit binary value is 00011001 [2].

(e) A compiler translates the entire source program in one operation and produces object code or an executable file [2]. It can also report syntax errors.

(f) A processor can execute only machine-code instructions directly. Pseudocode/high-level source code must therefore be translated into machine code before execution [2].

(g) The missing assignment is average ← total / 3 [2]. With the trace values, \(36\div3=12\).

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