Ask Question
19 October, 07:43

Can you find the reason that the following pseudocode does not perform as indicated in the comments? / / Find the error in the following pseudocode.

Module main ()

Declare Real value, result

/ / Get a value from the user.

Display "Enter a value."

Input value

/ / Get 10 percent of the value.

Call tenPercent (value)

/ / Display 10 percent of the value.

Display "10 percent of ", value, " is ", result

End Module

/ / The tenPercent function returns 10 percent

/ / of the argument passed to the function.

Function Real tenPercent (Real num)

Return num * 0.1

End Function

+2
Answers (1)
  1. 19 October, 11:40
    0
    The value of the variable "result" is never set anywhere in the code. In other words, variable "result" is declared but never given a value.

    Explanation:

    The call to the function "tenPercent (value) " on line 8 of the code returns the product of "value" and 0.1 i. e value * 0.1 as stated in the function declaration on lines 14, 15 and 16.

    The returned value from this call to the function "tenPercent (value) " should be stored in the variable "result". This can then be displayed as written on line 10.
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “Can you find the reason that the following pseudocode does not perform as indicated in the comments? / / Find the error in the following ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers