Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Part D: Reading and modifying data from a Direct Access File Write a different C program called Lab5D.c that performs an in-place sort by GPA
Part D: Reading and modifying data from a Direct Access File Write a different C program called "Lab5D.c" that performs an in-place sort by GPA of the data in "stdInfoDA.dat". This means that the records in the file must be re-arranged or sorted, using the GPA as the sorting key value. You may not use an array to hold all file data. You may only store records in at most two data structures within your program The records must be in order from highest to lowest GPA. To prove if your program works, start by reading in each record and then outputting the information to the monitor (stdout) until encountering end-of-file; during this process you can determine the number of records in the file. After closing and re-opening the file, perform a sort in much the same way that one sorts elements of an array - if two adjacent records are not in the correct order, then swap them. Use a temporary structure to swap records. You may use any algorithm for sorting. Finally, after the sort is finished, once again output all records to show that they appear in sorted order Note: Students should examine the content of the file stdInfoDA, dat', to verify that not all information in each record is human-readable as characters/digits/punctuation Using the data given above, the final sorted file output should look like: ID FIRSTNAME LASTNAME GPA YEAR 20 MINA ALAM 92.3 2016 30 JIM SMITH 78.2 2018 10 JACK DRELL 64.5 2018 40 ABED ALIE 54.0 2017
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started