Algorithms

EasyMediumHard
1234567891011121314151617181920212223242526272829303132333435363738
Question 33
Medium

An engineer is setting up a triangular hazard zone at a construction site using safety tape. The zone is in the shape of a right-angled triangle. One of the shorter perpendicular sides (the height) runs along an existing concrete wall, so safety tape is not needed on that side. The other two sides (the base and the hypotenuse) both require safety tape.

Hazard Zone

The engineer writes the following pseudocode to calculate the total length of safety tape required.

Line 5 and Line 6 contain logic errors.

1 SEND "Enter base: " TO DISPLAY
2 RECEIVE base FROM (REAL) KEYBOARD
3 SEND "Enter height: " TO DISPLAY
4 RECEIVE height FROM (REAL) KEYBOARD
5 SET hypotenuse TO base * base + height * height
6 SET totalTape TO base * hypotenuse
7 SEND "Tape needed: " & totalTape TO DISPLAY

Identify the error and write a new line of pseudocode to correct:

a.

Line 5

[2]
b.

Line 6

[2]

Algorithms Questions

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