University of Lethbridge - CPSC
Lab 8 Breakdown
LabsThis guide contains everything you need to fully understand and follow the code being created in Lab 8.
Assignment Summary
You’re reading a file called GPA.txt that contains student names and GPAs.
You’ll:
Store each student in a
struct.Use an array of those structs (up to 50 students).
Read from the file and populate the array.
Sort the array by GPA.
Display the min and max GPA (with names).
Calculate and show the average GPA.
Breakdown of What You’ll Do
Step 1: Define the student struct
Step 2: Create the obtainNamesAndGPAs function
Reads the file
GPA.txtFills the array of students
Updates the number of students (by reference)
Step 3: Create the sortGPA function
Sorts the array by GPA using simple bubble sort
Step 4: Create the displayMinMaxGPA function
Finds the min and max GPA
Prints their names (handles ties)
Step 5: Create the calcAvgGPA function
Loops through all GPAs
Returns the average
Step 6: Main function
Calls all the above in order
Displays final sorted list, min/max, and average
Keep reading this lesson
You've reached the end of the free preview. Unlock the rest of this lesson plus 27 more lessons in University of Lethbridge - CPSC.
- Unlimited coding questions
- Unlimited access to all classroom material
- Weekly live call for questions and guidance
- 3,000 AI tutor tokens / month
- Personal SQL database (3 MB)
- Progress tracking
Cancel any time.