asked 80.2k views
1 vote
Create a C++ program to compute the average of three tests or quizzes and display the score and average on distinct lines, and do it using arithmetic operators.

asked
User Dbaer
by
8.2k points

1 Answer

0 votes

#include <iostream>

#include <vector>

#include <numeric>

int main() {

std::vector<int> store(3);

for(int i=0;i<3;i++){

std::cout << i+1 << ". test result: ";

std::cin>>store[i];

}

for(int i=0;i<3;i++) {

std::cout << i+1 << ". test score: " << store[i] << std::endl;

}

std::cout << "Average: " << double(std::accumulate(store.begin(),store.end(),0.0)/store.size()) << std::endl;

return 0;

}

answered
User Lut
by
8.1k points

No related questions found