Can you find the reason that the following pseudocode does not perform as indica
ID: 3564614 • Letter: C
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
Explanation / Answer
The error lies here:
Display "10 percent of ", value, " is ", result
Here we have'nt assigned result any value, we just defined it. So it will give a garbage value.
The correct way to do it wud be
Display "10 percent of ", value, " is ", result*.1
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.