Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

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

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote