make swap make swapbig make reorderYou will also need data to test the second and third programs below. You should create your own data files that verify that your functions work correctly under all conditions (1 point). We will run your programs with the following commands:
swapbig < swapbig.dat reorder < reorder.dat
Copy the files swap.c and swaptest.c to your directory. Create the appropriate header file, swap.h, for the function defined in swap.c. Compile this program using your makefile with the command:
make swapRun the program and observe the output. Make sure you understand what this program is doing. On a piece of paper, draw the picture showing the trace of the code and state what the memory addresses are for the three variables, a, b, and c. You will turn in this paper to the TA before leaving the lab.
Write a function, swap_big(), which is given two pointers to floats and swaps the values in the cells pointed to such that the value pointed to by the first is less than (or equal to) the value pointed to by the second. The prototype for your function is:
void swap_big(float *a, float *b);Your data file, swapbig.dat, should show that your function works under all conditions. Write a driver to allow you to test this function for different pairs of floats when redirected from your data file. There is more than one way to do this program. You should use the swap() function from the previous problem to implement your function.
Write a function, reorder(), which is given three pointers to floats and reorders the values pointed to into ascending order. The prototype for this function is:
void reorder(float *a, float *b, float *c);i.e. when your function is done, the following should hold:
*a <= *b <= *cUse your swap_big() function from the previous problem to implement reorder(). Your data file, reorder.dat, should show that your function works under all conditions. Write a driver to allow you to test this function for different triplets of floats when redirected from your data file.
grade -lab12s1,ee160 *.c *.h *.dat makefileIf you are in Section 002 use:
grade -lab12s2,ee160 *.c *.h *.dat makefileIf you are in Section 003 use:
grade -lab12s3,ee160 *.c *.h *.dat makefileIf you are in Section 004 use:
grade -lab12s4,ee160 *.c *.h *.dat makefileYou should verify that you turned in things successfully, which you can do with the command (which simply leaves the file names off from the previous command).
grade -lab12s1,ee160 OR grade -lab12s2,ee160 OR grade -lab12s3,ee160