The teacher is marking a quiz: in answers, true is a right answer and false a wrong one. mark hands back how many were right and wrong through two references, right and wrong. Fill in the loop. With no questions, both are 0.
quiz_result({true, true, false, true})→'3 right, 1 wrong'quiz_result({})→'0 right, 0 wrong'string quiz_result(const vector<bool> &answers)#include <string>
#include <vector>
using namespace std;
void mark(const vector<bool> &answers, int &right, int &wrong) {
right = 0;
wrong = 0;
for (bool ok : answers) {
// your code here: add 1 to right or to wrong
}
}
string quiz_result(const vector<bool> &answers) {
int right = 0, wrong = 0;
mark(answers, right, wrong);
return to_string(right) + " right, " + to_string(wrong) + " wrong";
}
Run tries the examples. When they look right, Submit.