98%(246)240 out of 246 people found this document helpful
This preview shows page 5 - 11 out of 77 pages.
19.In every array, a subscript is out of bounds when it is _____.a.negativeb.0c.1d.99920. You can access every element of an array using a _____.5
Programming Logic and Design, 8eProgramming Exercises1.a. Design the logic for a program that allows a user to enter 12 numbers, then displays them in the reverse order of their entry.6
Programming Logic and Design, 8eb. Modify the reverse-display program so that the user can enter up to 12 numbers until a sentinel value is entered.
Programming Logic and Design, 8eSolutions 6-Pseudocode:startDeclarationsnum indexnum SIZE = 12num numbers[SIZE] = 0,0,0,0,0,0,0,0,0,0,0,0string CONTINUE = “Y”string moreNumbers getReady()while index < SIZE AND moreNumbers = CONTINUEgetNumbers()endwhilefinishUp()stopgetReady()index = 0output “Do you want to enter a number? (Y/N)”input moreNumbersreturngetNumbers()output “Enter a number for position ”, indexinput numbers[index]index = index + 18
Programming Logic and Design, 8eSolutions 6-output “Do you want to enter more numbers? (Y/N)”input moreNumbersreturnfinishUp()output “The numbers in reverse order are: ”while index > 0index = index – 1output numbers[index]endwhilereturn2.a. Design the logic for a program that allows a user to enter 12 numbers, then displays each number and its difference from the numeric average of the numbers entered.9