Question #187030

Find the Error The following pseudocode algorithm has an error. The program is supposed to ask the user for the length and width of a rectangular room, and then display the room's area. The program must multiply the width by the length in order to determine the area. Find the error. area = width times length. Display "What is the room's width?". Input width. Display "What is the room's length?". Input length. Display area.


Expert's answer

The calculation for area is done before the values are entered.

For calculating area of a rectangular room, the value of area = width × length

It must be set after taking length and width input and before displaying area.

The correct pseudocode will appear like

Display "What is the room's width?"

Input width

Display "what is the room's length?"

Input length

Area = width × length

Display area


LATEST TUTORIALS
APPROVED BY CLIENTS