Subprograms
1
0/6

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]

Subprograms Questions

Practise Edexcel GCSE Computer Science Subprograms with exam-style questions for GCSE Computer Science. 29 questions covering Built-in and user-devised subprograms, Functions versus procedures, and Global and local variables, matched to the Edexcel GCSE Computer Science (1CP2) specification and written in Paper 1 and Paper 2 style. Every question includes a full worked solution and mark scheme, so you can see where marks are awarded rather than just whether you got the answer right.

Next

Subprograms Questions

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