Skip to content

Course home

Sign up

Subprograms

EasyMediumHard
12345678910111213141516
Question 1

An engineer uses a program to calculate the total mechanical energy of a rollercoaster cart.

Lines 4 and 22 of the algorithm below are incomplete.

Complete the algorithm by stating what should be written in Box A (Line 4) and Box B (Line 22).

1
2  # Total Mechanical Energy of a Rollercoaster Cart
3
4  FUNCTION CalculateEnergy( [Box A] )
5
6
7  BEGIN FUNCTION
8
9      SET calc TO pMass * (9.81 * pHeight + 0.5 * pVelocity * pVelocity)
10     RETURN calc
11
12 END FUNCTION
13
14
15 # Main program
16
17 RECEIVE mass FROM (REAL) KEYBOARD
18 RECEIVE height FROM (REAL) KEYBOARD
19 RECEIVE velocity FROM (REAL) KEYBOARD
20
21
22 SET energy TO CalculateEnergy( [Box B] )
23
24 SEND "Total Energy: " & energy & " Joules" TO DISPLAY
25
26 IF (energy >= 1000) AND (energy <= 50000) THEN
27     SEND "Safe operation" TO DISPLAY
28 ELSE
29     SEND "Warning: Out of safe bounds" TO DISPLAY
30 END IF
[6]
Markscheme

Subprograms Questions

  1. GCSE
  2. /Computer Science
  3. /Subprograms

29 exam-style questions on Edexcel GCSE Computer Science Subprograms, covering Built-in and user-devised subprograms, Functions versus procedures, and Global and local variables. Each one has a worked solution and a mark scheme showing where the marks go.

Question bank