1. Display Function Implement a function to display the contents of the patient_list array. Add code to call this function. Note that there are multiple places where this function needs to be called. Look for the // TODO comments to find the correct locations. Compile and test your program. Make sure that your output is formatted similarly to the sample output shown at the end of this document. The sorting part does not need to work yet. Take a screenshot of a sample output and upload the picture as part of your assignment submission. 2. Sorting the array by Age Implement the code to sort the contents of the patient_list array based on the value stored in the age field. To do this you will need to implement code that relies on the qsort function from the C Standard library (see http://www.cplusplus.com/reference/cstdlib/qsort/). As shown in the reference, this code requires two parts: A function that compares two patient elements, based on the value stored in the age field. A call to the qsort function, which includes the array to be sorted, the number of elements in the array, the size of each array element and the function used to compare the array elements. Add code to call the qsort function, using the age comparison function that you implemented. This code should be placed just under the appropriate // TODO comment in main(). Compile and test your program. Make sure that your output is formatted similarly to the sample output shown at the end of this document. The first sorted list should be correct now. Take a screenshot of a sample output and upload the picture as part of your assignment submission. Sorting the array by Balance Due
1. Display Function
- Implement a function to display the contents of the patient_list array.
- Add code to call this function. Note that there are multiple places where this function needs to be called. Look for the // TODO comments to find the correct locations.
- Compile and test your program.
- Make sure that your output is formatted similarly to the sample output shown at the end of this document. The sorting part does not need to work yet.
Take a screenshot of a sample output and upload the picture as part of your assignment submission.
2. Sorting the array by Age
- Implement the code to sort the contents of the patient_list array based on the value stored in the age field. To do this you will need to implement code that relies on the qsort function from the C Standard library
(see http://www.cplusplus.com/reference/cstdlib/qsort/). As shown in the reference, this code requires two parts: - A function that compares two patient elements, based on the value stored in the age field.
- A call to the qsort function, which includes the array to be sorted, the number of elements in the array, the size of each array element and the function used to compare the array elements.
- Add code to call the qsort function, using the age comparison function that you implemented. This code should be placed just under the appropriate // TODO comment in main().
- Compile and test your program.
- Make sure that your output is formatted similarly to the sample output shown at the end of this document. The first sorted list should be correct now.
Take a screenshot of a sample output and upload the picture as part of your assignment submission.
Sorting the array by Balance Due
- Implement the code to sort the contents of the patient_list array based on the value stored in the balance field. To do this you will need to implement code that relies on the qsort function from the C Standard library
(see http://www.cplusplus.com/reference/cstdlib/qsort/). As shown in the reference, this code requires two parts: - A function that compares two patient elements, based on the value stored in the balance field.
- A call to the qsort function, which includes the array to be sorted, the number of elements in the array, the size of each array element and the function used to compare the array elements.
- Add code to call the qsort function, using the balance comparison function that you implemented. This code should be placed just under the appropriate // TODO comment in main().
- Compile and test your program.
- Make sure that your output is formatted similarly to the sample output shown at the end of this document. The second sorted list should be correct now.
Take a screenshot of a sample output and upload the picture as part of your assignment submission.
Sorting the array by Patient Name
- Implement the code to sort the contents of the patient_list array based on the value stored in the name field. To do this you will need to implement code that relies on the qsort function from the C Standard library
(see http://www.cplusplus.com/reference/cstdlib/qsort/). As shown in the reference, this code requires two parts: - A function that compares two patient elements, based on the value stored in the name field. Because name data is stored in an array of characters, you cannot use the relational operators (<, >, <=, … ) to do the comparison, instead you should use a function from the C Standard Library to determine the order of the names, see (http://www.cplusplus.com/reference/cstring/strncmp/).
- A call to the qsort function, which includes the array to be sorted, the number of elements in the array, the size of each array element and the function used to compare the array elements.
- Add code to call the qsort function, using the name comparison function that you implemented. This code should be placed just under the appropriate // TODO comment in main().
- Compile and test your program.
- Make sure that your output is formatted similarly to the sample output shown at the end of this document. The third and final sorted list should be correct now.
Take a screenshot of a sample output and upload the picture as part of your assignment submission.
Sample (partial) Output for Completed Solution:
Note: this sample output only shows the existing list of patients ; your output should additionally show the entry with your details.
OUTPUT IN IMAGES


Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 2 images









