178k views
0 votes
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

1 Answer

4 votes

Answer:

Call raiseToPower (2, 1.5) '

or

raiseToPower (Real value, Integer power)

Step-by-step explanation:

To solve this, first organize the pseudo code,

1) main ()

2) Call raiseToPower (2, 1.5)

3) End Module

4) Module

5) raiseToPower (Real value, Integer power)

6) Declare Real result

7) Set result=value^power

8) Display result

9) End Module

The first three lines in pseudo code are representing the main module. While lines 4-9 shows the definition of module that is being called in main function.

If we look at the raiseToPower definition at line5, we can see that it is requiring any real value for the base number. However, for power, it defines only integers.

But, in the main function, 1.5 is placed as a power that is not an integer. Therefore, this is the error in pseudo code. It should be changed to any integer.

Alternatively, change the integer power to real power to avoid this error.

User Meanteacher
by
5.7k points