Write a program that will read in grades the number of which

Write a program that will read in grades, the number of which is also input by the user. The program will find the sum of those grades and pass it, along with the number of grades, to a function which has a \"pass by reference\" parameter that will contain the numeric average of those grades as processed by the function. The main function will then determine the letter grade of that average based on a 10-point scale. Enter the nuttier of grades 3 Enter a numeric grade between 0-100 90 Enter a numeric grade between 0-100 80 Enter a numeric grade between 0-100 50 the grade is c

Solution


// C++ code to determine grade of a student

#include <iostream>
using namespace std;

// pass by reference
double avg(double &average, double sum, int size)
{
average = sum/size;
}

int main()
{
int size;
double sum = 0;
double numericGrade;

cout << \"Enter number of grades: \";
cin >> size;

for (int i = 0; i < size; ++i)
{
cout << \"Enter a numeric grade between 0-100: \";
cin >> numericGrade;

sum = sum + numericGrade;
}

double average;
avg(average ,sum, size);
char letterGrade;

if(average >= 90)
letterGrade = \'A\';
else if(average >= 80)
letterGrade = \'B\';
else if(average >= 70)
letterGrade = \'C\';
else if(average >= 60)
letterGrade = \'D\';
else
letterGrade = \'F\';

cout << \"\ The grade is \" << letterGrade << endl;
}

/*
output:

Enter number of grades: 3
Enter a numeric grade between 0-100: 90
Enter a numeric grade between 0-100: 80
Enter a numeric grade between 0-100: 50

The grade is C


*/

 Write a program that will read in grades, the number of which is also input by the user. The program will find the sum of those grades and pass it, along with
 Write a program that will read in grades, the number of which is also input by the user. The program will find the sum of those grades and pass it, along with

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site