Question 1(e) 2025 · May-June · Paper 42 · 0 marks
Reveal official mark-scheme answer


Official answer for Question 1
Part (e)
Question 1
mark for:
Question 7
- Calculate() function header (and end where appropriate)
- Looping until the stack is empty
- Calling Pop() repeatedly within loop and storing/using return value
- … working out if return value from Pop() call is an operator or a number / alternating between operator and number
- Select to determine if the operator is +, -, /, * or ^ and attempt the matching calculation
- … performing correct calculation using operator, number
- … updating total from previous loops and returning this final value
Show text version of question
Question 1
Part (e)
Question 1
A program reads data from a text file and stores it in a stack. The stack Stack is stored as a 1D
array of up to 20 elements. The pointer TopOfStack stores the index of the last element stored in the stack.
Part (e)
The values stored in the stack are used to perform mathematical operations.
number.
The next value will be a mathematical operator and the next value will be the number to apply to the calculation. This is repeated until there are no values left in the stack. There will always be a number following a mathematical operator.
For example, the contents of a stack are:
10 TopOfStack +
Question 3
–
Why this question appears here
49% assigned-topic match · Programming › Constructs
Topic-match percentages estimate how closely each question fits the selected syllabus topic. They are a guide for choosing stricter or broader practice.
Permanent source page: Educate A Change · From 9618_s25_qp_42.pdf
