The output should be like this:
Grade 1: 90
Grade 2: 86
Grade 3: 95
Grade 4: 76
Grade 5: 92
Grade 6: 83
Grade 7: 100
Grade 8: 87
Grade 9: 91
Grade 10: -1
Average Grade: 88%
/******************************************************************
#include <iostream>
using namespace std;
/******************************************************************
* This function will get the Grades!!
****************************************************************/
int getGrades()
{
const int SIZE = 10;
int Grades[SIZE];
int average[SIZE];
average = 0;
for (int i = 0; i < SIZE; i++)
// Fill the list
{
cout << "Grade " << i + 1 << ": ";
cin >> Grades[i];
average = average + Grades[i];
}
// get Average
average = average / SIZE;
cout << "Average Grade: " << average
<< "%"
<< endl;
}
/**************************************************
* main function
****************************************************/
int main()
{
// display the result
This is my out put!
The output should be like this:
Grade 1: 90
Grade 2: 86
Grade 3: 95
Grade 4: 76
Grade 5: 92
Grade 6: 83
Grade 7: 100
Grade 8: 87
Grade 9: 91
Grade 10: 1
Average Grade: 89%
I don't how can I make it -1 and average grade should be % 88. How can I do that? Thanks a lot!
Yes, I did change that and I think I'm very close. I came up with this loop but there is something need to be fixed. My output needs to be like that Exp: Average Grade: 88%\n
This is my code so far:
int getGrades()
{
const int SIZE = 10;
int grades[SIZE];
int average = 0;
for (int i = 0; i < SIZE; i++)
// Fill the list
{
cout << "Grade " << i + 1 << ": ";
cin >> grades[i];
average += grades[i];
if (grades >= 0)
average++;
else
return -1;
}
This is so far what I got for the output. The Exp is the right output. So when I run my program through textBed it gives me the result below. I'm very close but I still need an advice.
int main()
{
getGrades();
getAverage();
return 0;
}
int getGrades()
{
int grades[10];
for (int i = 1; i <= 10; i++)
{
cout << "Grade " << i << ": "; //prompts user for grades
cin >> grades[i]; // adds values to array
}
}
int getAverage()
{
int grades[10];
int average;
int sum = 0;
int count = 0;