Please help!!!
trying to use a function to calculate average grade and ive fallen off the tracks....
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
|
#include<iostream>
using namespace std;
void findAverage(int &, int &, int);
void findAverage(float totalSum, int numOfGrades, float& avgGrade)
{
avgGrade = totalSum / numOfGrades;
}
int main()
{
int numOfGrades, grade, i;
float totalSum, avgGrade;
cout << "Enter the number of grades" <<endl;
cin >> numOfGrades;
for(i=0; i < numOfGrades; i++)
{
cout << "Enter a numeric grade between 0-100" <<endl;
cin >> grade;
}
if(grade <= 59) grade = F;
if(grade <= 69 && grade >=60) avgGrade = D;
if(grade <=79 && grade >=70) avgGrade = C;
if(grade <=89 && grade >=80) avgGrade = B;
if(grade<=100 && grade >=90) avgGrade = A;
cout << "The grade is " << findAverage(
system("pause");
return 0;
}
|
Topic archived. No new replies allowed.