Ask Question

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

+3
Answers (1)
  1. 6 February, 12:14
    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 & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers