Question: In C programming, Example Let the input file contain the following numbers: {-5.2, 3.7, -11.9, 4.4, 3.7, 20.2, -6.0, 8.2, 14.6, -20.6}. Assuming that you
In C programming, 
Example
Let the input file contain the following numbers: {-5.2, 3.7, -11.9, 4.4, 3.7, 20.2, -6.0, 8.2, 14.6, -20.6}. Assuming that you are sorting from largest to smallest, your output should look like the below text:
-5.2 3.7 -5.2 3.7 -5.2 -11.9 4.4 3.7 -5.2 -11.9 4.4 3.7 3.7 -5.2 -11.9 20.2 4.4 3.7 3.7 -5.2 -11.9 20.2 4.4 3.7 3.7 -5.2 -6 -11.9 20.2 8.2 4.4 3.7 3.7 -5.2 -6 -11.9 20.2 14.6 8.2 4.4 3.7 3.7 -5.2 -6 -11.9 20.2 14.6 8.2 4.4 3.7 3.7 -5.2 -6 -11.9 -20.6
Program Flow Prior to your main processing loop, you should: 1. Explain the program to the user by calling a function that prints the explanation to the screen. 2. Ask the user as to whether the sort is to be in ascending or descending order. Store this choice in a flag variable that will later be passed into your sorting function. 3. Open the file "data.txt" that contains the data to be sorted. Create the file yourself. 4. Check to make sure the file exists. Main Processing Loop: 1. Read the next value from your input file. Assume that the maximum number of input points is 50. Use a Macro to define this maximum size. If EOF is encountered your program should terminate reading the file. If a value is read, continue to the next step. 2. Assuming that there was a new input to read, call your insertion sort function and pass as arguments the number of points thus far sorted, the new input point, the ascending/descending flag and a reference (pointer) to the sorted array. 3. Using the insertion sort algorithm, place the new point in its proper location in the array, and return back to your main function. Do not read or display anything from your function. 4. Increment the number of points thus far sorted. 5. Print out your thus-far sorted array in a horizontal fashion to the screen (see example). 6. Repeat step 1
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
