Ask Question
29 August, 07:58

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

+5
Answers (1)
  1. 29 August, 09:26
    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?
Find 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 and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers