Question: The programmer intended the following pseudocode to get five sets of two numbers each, calculate the sum of each set, and calculate the sum of
The programmer intended the following pseudocode to get five sets of two numbers each, calculate the sum of each set, and calculate the sum of all the numbers entered. It will not function as intended, however. Find the error.
// This program calculates the sum of five sets of two numbers. Declare Integer number, sum, total Declare Integer sets, numbers Constant Integer MAX_SETS = 5 Constant Integer MAX_NUMBERS 2 Set sum Set total = 0; = 0; For sets = 1 To MAX NUMBERS End For = For numbers = 1 To MAX SETS Display "Enter number ", numbers, " of set ", sets, "," Input number; Set sum = sum + number Display "The sum of set ", sets, " is ", sum, Set total total + sum Set sum = 0 End For Display "The total of all the sets is ", total, "1 11 11 11
Step by Step Solution
3.48 Rating (158 Votes )
There are 3 Steps involved in it
The error in the pseudocode is that the first For loop should iterate over MAXSETS not MAXNUMBERS Th... View full answer
Get step-by-step solutions from verified subject matter experts
