Skip to content

Course home

Structured programming and subroutines (procedures and functions)

Structured programming and subroutines (procedures and functions)

EasyMediumHard
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
Question 8

The area of a rectangular floor (in square centimetres) is calculated using the following formula:

area (in cm2)=length×width \text{area (in cm}^2\text{)} = \text{length} \times \text{width} area (in cm2)=length×width

To convert this area to square metres (m2\text{m}^2m2), the area in cm2\text{cm}^2cm2 is divided by 10 00010\,00010000.

The total cost of carpeting is then found by multiplying this area in m2\text{m}^2m2 by the price per square metre.

The algorithm below is designed to output the total carpet cost for a room with a length of 500 cm, a width of 400 cm, and a carpet price of £25 per square metre.

A subroutine called calcCarpetCost has been developed as part of the algorithm.

Complete the program by identifying the correct term from the pool of options to fill each of the six empty gaps.

Options Pool

  • length
  • width
  • pricePerSqMetre
  • areaSqCm
  • areaSqMetres
  • areaSqCm / 10000
  • areaSqCm * 10000
  • areaSqCm MOD 10000
  • RETURN
  • SUBROUTINE
  • OUTPUT
  • calcCarpetCost
  • calcCarpetArea
  • 500

Subroutine Pseudo-code

SUBROUTINE calcCarpetCost([Gap 1], width, [Gap 2])
    [Gap 3] ← length * width
    areaSqMetres ← [Gap 4]
    totalCost ← areaSqMetres * pricePerSqMetre
    [Gap 5] totalCost
ENDSUBROUTINE

OUTPUT [Gap 6](500, 400, 25)
[6]
Markscheme

Structured programming and subroutines (procedures and functions) Questions

  1. GCSE
  2. /Computer Science
  3. /Structured programming and subroutines (procedures and functions)

131 exam-style questions on AQA GCSE Computer Science Structured programming and subroutines (procedures and functions). Each one has a worked solution and a mark scheme showing where the marks go.

Question bank