Thursday
March 23, 2017

Post a New Question

Posted by on Friday, August 30, 2013 at 8:42pm.

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

  • programming - , Friday, August 30, 2013 at 10:42pm

    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.

Answer This Question

First Name:
School Subject:
Answer:

Related Questions

More Related Questions

Post a New Question