Assignment 4 : CIS 208

Assigned: February 16, 2005
Due: February 23, 2004,    by 5:00 PM.  

Turn in hard copies to the CIS Main office and
email your source code (not compiled programs) to sdg5476@ksu.edu.

This assignment is worth 10 points.

Write a program in C that does the following:
Create a randomly filled integer pointer array of a size determined by the user. 
Sort this sequence and print out both the original sequence and sorted sequence.

Specifically:
1) Read in an integer from the user as a command line argument. This is the size.
2) Allocate the required space for an array of the desired size.
3) Fill this array with random integers between 0 and 100. This is our unsorted sequence.
4) Sort the sequence in ascending order. 
5) Print out both the unsorted sequence and sorted sequence.

Notes:  Since this is for pointer practice,  do not use any array notation. 
            Every thing must be done in pointers.  Make no assumptions on the size
            of the sequence.   Ensure there are no memory leaks.  All allocated memory
            must be reclaimed by the system.

           You may use what ever sorting algorithm you wish, but you may not use
           C's built-in sorting functions.   The main page has a link to the source code for
           many different sorting algorithms.  
          
           stdlib.h has many functions that might be useful for this assignment. 
            malloc(), calloc(), free(), atoi(), srand(), rand() and others may help finding the solution.

Sample output: 
%> assign4  10
92      1
1        30
49      43
74      49
52      52
88      53
53      74
90      88
43      90
30      92
%>

%> assign4 not_a_number
please give an integer
%>