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.

User Dbaer
by
4.6k 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;

}

User Lut
by
4.4k points