Question: Arrays as function arguments The program given below is a revision of the previous array lab. In this assignment you are to make changes in

Arrays as function arguments
The program given below is a revision of the previous array lab. In this assignment you are to make changes in
your code for GPA to use functions and pass an array as a function argument. You are also asked to find the largest
value in the array.
Input is from a file, output is to a file.
Write a function to print the headings.
Write a function to find and return the largest value in the array. The function shall have two arguments: the
array of grades and an integer giving the count of the number of values in the array. The largest grade shall
be returned through the function name (return statement).
Write a function to write out the grades and the largest grade. The function shall have three parameters: the
output file object, the array of grades, an integer giving the count of the number of values in the array, and
the largest grade.
Test the code with the test data: 89,67,93,78,95,77,88,65,91,68,71,86
Use the following list of changes to the previous GPA pseudocode
Create a function to print the headings into the output file.
Add a function to find and return the largest value in the array.
Output is now:
a. Print the grades from the array.
b. Print the average|
c. Print the largest value.
Output:
GPA
Here is the code from the previous assignment
#include
#include
#include
#include
using namespace std;
int main()
{
double grades[11];
int sub =0;
int count =0;
double total =0;
ifstream fin;
ofstream fout;
fout.open("output.txt");
fout "GPA:" endl;
cout "Enter the GPA of each student:" endl;
while (sub 11)
{
cin >> grades[sub];
fout grades[sub] endl;
total = total + grades[sub];
sub++;
count = sub;
}
fout endl;
double average = total / count;
fout "Average is ";
fout fixed setprecision(1) average endl;
fout.close();
return 0;
}
Arrays as function arguments The program given

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Accounting Questions!