Logic7e_Solutions_ch06 - Programming Logic and Design 7e...

This preview shows page 1 - 6 out of 57 pages.

Programming Logic and Design, 7eSolutions 6-Programming Logic and Design, 7th EditionChapter 6Exercises1.a. Design the logic for a program that allows a user to enter 15 numbers, then displays them in the reverse order of their entry.
1
Programming Logic and Design, 7e
b. Modify the reverse-display program so that the user can enter up to 15 numbers until a sentinel value is entered.
Programming Logic and Design, 7eSolutions 6-Pseudocode:startDeclarationsnum indexnum SIZE = 15num numbers[SIZE] = 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0string CONTINUE = “Y”string moreNumbers = CONTINUEgetReady()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 + 13
Programming Logic and Design, 7eSolutions 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 15 numbers, then displays each number and its difference from the numeric average of the numbers entered.
4
Programming Logic and Design, 7e
b. Modify the program in Exercise 2a so that the user can enter up to 15 numbers until a sentinel value is entered.

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture