Bifalgorithm post · Computer science one · Passing Arrays of Structures
How do you pass an array of structures to a function to compute an average GPA?
How do you pass an array of structures to a function to compute an average GPA? (Computer science one · Passing Arrays of Structures) — "We often also have nee…
Ideas in this flowchart
- Passing arrays of structures to functions
- A student roster can be passed to compute the average GPA
- The function is declared as computeAverageGpa(const Student *roster, int n)
- roster refers to the array of Student structures
- n specifies the number of students in the roster
- The function iterates through the roster
- Each student's GPA is added to sum
- The function returns sum divided by n
- The array of structures is not passed by value
- The bytes for each Student structure are not copied onto the call stack