expand icon
book Programming Logic and Design, Introductory 7th Edition by Joyce Farrell cover

Programming Logic and Design, Introductory 7th Edition by Joyce Farrell

Edition 7ISBN: 1285225562
book Programming Logic and Design, Introductory 7th Edition by Joyce Farrell cover

Programming Logic and Design, Introductory 7th Edition by Joyce Farrell

Edition 7ISBN: 1285225562
Exercise 1

a. Design the logic for a program that allows a user to enter 15 numbers, then displays them in the reverse order of entry.

b. Modify the reverse-display program so that the user can enter any amount of numbers up to 15 until a sentinel value is entered.

Step-by-step solution
Verified
like image
like image

Step 1 of 2

Flowchart that prints numbers in reverse order

    <div class=answer> Flowchart that prints numbers in reverse order   b) Program Start Declarations num SIZE=15 num Numbers[15] num index=0 housekeeping() while index<size>      < p=>     </size><> InputElements() if value!=sentinel Numbers[Index]=value Index=Index+1 endif endwhile Index=SIZE-1 while index>=0 OutputElements() endwhile finish() stop housekeeping() Output “Enter Values” return InputElements() Input Value Index=Index+1 return OutputElements() output Numbers[Index] Index=Index-1 return finish() output “End of job” return

b)

Program

Start

Declarations

num SIZE=15

num Numbers[15]

num index=0

housekeeping()

while index < p=""> <>

InputElements()

if value!=sentinel

Numbers[Index]=value

Index=Index+1

endif

endwhile

Index=SIZE-1

while index>=0

OutputElements()

endwhile

finish()

stop

housekeeping()

Output “Enter Values”

return

InputElements()

Input Value

Index=Index+1

return

OutputElements()

output Numbers[Index]

Index=Index-1

return

finish()

output “End of job”

return


Step 2 of 2

close menu
Programming Logic and Design, Introductory 7th Edition by Joyce Farrell
cross icon