51.4k views
1 vote
The following pseudocode algorithm with 6 steps has an error. It is supposed to use values input for a rectangular room’s length and width to calculate and display its area. Find the error and explain in writing how you would fix this algorithm. You can write your answers to a word document names lab1-yourname.doc for submission. 1) area = width × length. 2) Display to the user "What is the room’s width?". 3) Input width. 4) Display to the user "What is the room’s length?". 5) Input length. 6) Display area.

1 Answer

3 votes

Answer:

Correct algorithm is here.

1) Display to the user "What is the room’s width?".

2) Input width.

3) Display to the user "What is the room’s length?".

4) Input length.

5) area = width × length.

6) Display area.

Step-by-step explanation:

The algorithm given in the question is wrong because we can not perform any operation on the variable before taking their value.It will give error.

According to the question,it will calculate area first then it will take input value of length and width.But we have to take input length and width first then we can find the area.

User Adamzwakk
by
6.5k points