Kodewick
Start learning →
Basic←→0 / 60

Everyone passed

#013BasicLoops4 min

The teacher wants to know if the whole class passed the quiz (60 is a pass). Write all_passed(scores): true if everyone passed, false as soon as one score is under 60. No scores gives true.

Examples
all_passed({75, 60, 88})→True
all_passed({90, 59})→False
The functionbool all_passed(const vector<int> &scores)
main.cpp
#include <vector>
using namespace std;

bool all_passed(const vector<int> &scores) {
    for (int s : scores) {
        // your code here: if one is under 60, return false right away
    }
    return true;
}
Ctrl + Enter runs too
Result

Run tries the examples. When they look right, Submit.