Homework Assignment 5
Assigned: Wednesday, Feb 21.
Due: Wednesday, Feb 28.
Read: Sections 5.1, 5.2, 5.3.
Program: Finish the program Sort1.C which we began in class.
- Functional Description of Program
The user is prompted to input 10 positive integers. The
integers are then printed, one per line, in descending size
order. The program then terminates.
- Algorithm Description
In class we have developed procedure objects getPositive
and fillArray. These procedures take care of the input.
We have described the algorithm by which the numbers are
output in descending order. We review the algorithm
step-by-step:
- Call a procedure which returns the index in the array
of the largest integer in the array.
- If the largest integer in the array is 0, you are done.
- Else: print the integer and place a 0 in the location
where the integer was.
- Repeat from step 1. (Use a while or do while loop).
- Hints
Write first the procedure which returns the index in
the array of the largest integer in the array. Test this
function thoroughly before throwing it into the loop which
prints all integers in descending order.