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.
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