C
Computers and Technology , 29.03.2022 05:21

Module main()
Call getCalories()
End Module
Module getCalories()
Declare Real calories
Display "How many calories are in the first food?"
Input calories
Declare Real calories
Display "How many calories are in the second food?"
Input calories
End Module
3. Find the potential error in the following pseudocode.
Module main()
Call squareNumber(5)
End Module
Module squareNumber(Integer Ref number)
Set number = number^2
Display number
End Module
4. Find the error in the following pseudocode.
Module main()

Module raiseToPower(Real value, Integer power)
Declare Real result
Set result = value^power
Display result
End Module
Call raiseToPower(2, 1.5)
End Module


Module main()
Call getCalories()
End Module
Module getCalories()
Declare Real calories
Display

Step-by-step answers

answer
Answered by an experienced expert Nitin Arora

2  

Module main()
Call getCalories()
End Module
Module getCalories()
Declare Real calories
Display "How many calories are in the first food?"
Input calories
Declare Real calories
Display "How many calories are in the second food?"
Input calories
End Module

The variable calories is declared twice in the module getCalories(). You cannot have two variables with the same name in the same scope. It will cause an error.

3. You can't normally pass a non-variable argument into a reference variable. It causes an error.

4 There is a data type mismatch between the 2nd argument being passed to the module raiseToPower() which is of the type Real and the data type of the parameter variable which is Integer. Arguments and parameter variables must be of the same data type. 

Show answers

Other questions on the subject: Computers and Technology

C
Computers and Technology, 09.03.2021 20:52
6.Draw a Binary Tree from the following array data and sort the resulting tree using Heap sort algorithm.
Answers: 0
C
Computers and Technology, 11.11.2020 16:51
Garry is a record executive who is building a data table to include in a presentation about one of his artists. The table is meant to show sales during the first five months of the year. What should Garry most likely do with this table to present the data he needs to share? He should right-click on the table, highlight Insert, choose Insert Columns Below, and type into that row the names of the months corresponding
Answers: 0
C
Computers and Technology, 02.12.2021 07:48
how did joseph jacquard contribute to the evolution of computer
Answers: 0
C
Computers and Technology, 26.08.2021 09:41
What characteristics describes ECC memory?
Answers: 0

Popular questions today: