Find the error in the following pseudocode. Module main() Call raiseToPower(2, 1
ID: 3787374 • Letter: F
Question
Find the error in the following pseudocode.
Module main()
Call raiseToPower(2, 1.5)
End Module
Module raiseToPower(Real value, Integer power)
Declare Real result
Set result = value^power
Display result
End Module
2. Find the error in the following pseudocode.
Module main()
Call getNames()
End Module
Module getNames()
Declare Sting name
Display "What is the name of the first student?"
Input name
Declare String name
Display "What is the name of the second student?"
Input name
End Module
Find the potential error in the following pseudocode.
Module main()
Call setDouble(10.5)
End Module
Module setDouble(Int Ref num)
Set num = num*2
Display num
End Module
Find the error in the following pseudocode.
Module main()
Declare Integer month
Call getMonth()
Display "Your birthday is in month “, month, “.”
End Module
Module getMonth()
Display "Enter the month of your birthday"
Input birthMonth
End Module
Explanation / Answer
Hi, I have mentioned error in each question .
Please let me know in case of any issue.
Find the error in the following pseudocode.
Module main()
Call raiseToPower(2, 1.5) // ERROR: first argument should be real number and second argument should be integer
End Module
Module raiseToPower(Real value, Integer power)
Declare Real result
Set result = value^power
Display result
End Module
2. Find the error in the following pseudocode.
Module main()
Call getNames()
End Module
Module getNames()
Declare Sting name
Display "What is the name of the first student?"
Input name
Declare String name // ERROR: declaring same variable twice in same scope
Display "What is the name of the second student?"
Input name
End Module
3. Find the potential error in the following pseudocode.
Module main()
Call setDouble(10.5) // ERROR: setDouble method takes integer reference, not double or float
End Module
Module setDouble(Int Ref num)
Set num = num*2
Display num
End Module
4. Find the error in the following pseudocode.
Module main()
Declare Integer month
Call getMonth() // ERROR: we are not receiving returning value of getMonth
Display "Your birthday is in month “, month, “.” // always print 0
End Module
Module getMonth()
Display "Enter the month of your birthday"
Input birthMonth
End Module
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.