162k views
3 votes
The following code will not display the results expected by the programmer. Can you find the error? Declare Real lowest, highest, average Display "Enter the lowest score." Input lowest Display "Enter the highest score." Input highest Set average = low + high / 2 Display "The average is ", average, "."

User Saprina
by
3.6k points

2 Answers

3 votes

Final answer:

The error in the code is that there is a typo in the calculation of the average. Instead of using the variables lowest and highest, the code uses low and high. To fix the error, the code should be updated to use the correct variable names.

Step-by-step explanation:

The error in the code is that there is a typo in the calculation of the average. Instead of using the variables lowest and highest, the code uses low and high. This will result in an error when trying to calculate the average.

To fix the error, the code should be updated to use the correct variable names:

Declare Real lowest, highest, average

Display "Enter the lowest score."

Input lowest

Display "Enter the highest score."

Input highest

Set average = lowest + highest / 2

Display "The average is ", average, "."

User IamAlexAlright
by
3.3k points
6 votes

Final answer:

The error in the code is that the variable names used for calculating the average are incorrect. The corrected line of code should be 'Set average = lowest + highest / 2'. This will ensure that the correct variable values are used to calculate the average.

Step-by-step explanation:

The error in the code is that the variable names used for calculating the average are incorrect. Instead of 'low' and 'high', it should be 'lowest' and 'highest'. So, the corrected line of code should be:

Set average = lowest + highest / 2

This will ensure that the correct variable values are used to calculate the average.

User Tsimmi
by
3.2k points