Store a student’s four exam scores: 95, 87, 90, 89
Calculate and store the sum of those four test score.
Calculate and store the average of these scores.
Display the sum and average as shown below:
OUTPUT:
The sum of your scores is: 361
The average of your scores is: 90.25
#include <iostream>
using namespace std;
int main () {
int scores[4] = {95, 87, 90, 89};
int total_score = 0;
double average_score;
cout << "you scroes: ";
for (int i = 0; i < 4; i++) {
cout << scores[i] << " ";
total_score += scores[i];
}
average_score = total_score / 4.0;
cout << "\nThe sum of your scores is: " << total_score;
cout << "\nThe average of your scores is: " << average_score;
return 0;
}
Comments
Leave a comment