Find Bugs in the pseudocode

start
Declarations
num category
num SIZE = 5
num QUIT = 9
num sales[SIZE] = 0, 0, 0, 0, 0
string HEAD1 = "Sales"
string HEAD2 = "Category Number of Sales"
output "Enter category ", QUIT, " to quit "
input category
while category = QUIT
if category >= 1 AND category < SIZE then
sales[category + 1] = sales[category - 1] + 1
else
output "Invalid category"
endif
output "Enter category ", QUIT, " to quit "
input category
endif
output HEAD1
output HEAD2
category = 0
while category <= SIZE
output category + 1, sales[category]
category = category + 1
endwhile
stop

1 answer

Two bugs found.

There are two "while" bit only one "endwhile", and also one "if" but two "endif". Thus it appears that the second "endif" should be an "endwhile".

Also, you have "while category = QUIT" when it seems you wish to loop _until_ that condition.
Similar Questions
  1. // This program counts how many sales are made// in each of five categories of products start Declarations num category num SIZE
    1. answers icon 1 answer
  2. Find Bugs in the pseudocode// A high school is holding a recycling competition // This program allows a user to enter a
    1. answers icon 2 answers
    1. answers icon 1 answer
    1. answers icon 1 answer
more similar questions