Site hosted by Angelfire.com: Build your free website today!

 

Program 36
C++ 

 

 


Sorting high-low and low-hi.  Using 4 functions.

 

·        This program will store 10 random numbers.

 

Oval Callout: Save your chubby little programs!Your main must look like this…

         void main(){

                          store(num);

                          print(num);

                          hisort(num);

                          print(num);

                          losort(num);

                          print(num)}

            10 numbers have been stored

List(-200,56,2000,-100,2340,-567,298,4,-101,521)

High Low List{2340,2000,521,298,56,4,-100,-101,-200,-567}

Low High List{-567,-200,-101,-100,4,56,298,521,2000,2340}

 
Output…

 

 

 

 

In the one print function you must be able to print a different word leader (new list or list).  This can be done by having a counter in the function that will print LIST on first entry (count= =1) or High Low List (count= =2) or Low High List (count= =3)

 

Hint #1: Use a static local variable.  It will initialize on the first pass only and will preserve

             Static int count = 0;

 

Hint #2: Your random statement will be random(3350)-999

 

Teach us to delight in simple things,
And mirth that has no bitter springs;
Forgiveness free of evil done,
And love to all men 'neath the sun.
                      -Rudyard Kipling