✅ The verified answer to this question is available below. Our community-reviewed solutions help you understand the material better.
#define main1 main
/** Question C1
What is output of the program?
*/
//Q-stl-1: std::ranges::for_each; std::ranges::count; std::ranges::count_if;
//std::ranges::all_of; std::ranges::none_of
#include <iostream>
#include <vector>
#include <algorithm>
int main1() {
std::vector<int> v = {5, 3, -4, -5, -4, -2, 1, -3, -1, 3};
int c1 = std::ranges::count(v, -3);
int c2 = std::ranges::count_if(v, [](int x){
return x % 2 == 0;
});
bool b1 = std::ranges::all_of(v, [](int x){
return x >= -5;
});
bool b2 = std::ranges::none_of(v, [](int x){
return x > 4;
});
std::ranges::for_each(v, [](int &x){
x = x + 1;
});
int sum = 0;
for (auto x : v) sum += x;
std::cout << c1 << "|" << c2 << "|" << b1 << "|" << b2 << "|" << sum;
return 0;
}
Get Unlimited Answers To Exam Questions - Install Crowdly Extension Now!