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:
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;
int sub ;
int count ;
double total ;
ifstream fin;
ofstream fout;
fout.openoutputtxt;
fout "GPA:" endl;
cout "Enter the GPA of each student:" endl;
while sub
cin gradessub;
fout gradessub endl;
total total gradessub;
sub;
count sub;
fout endl;
double average total count;
fout "Average is ;
fout fixed setprecision average endl;
fout.close;
return ;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
