Question: The existing code below reads in a random seed and generates a sequence of numbers and then prints it. It then attempts to use the

The existing code below reads in a random seed and generates a sequence of numbers and then prints it. It then attempts to use the count_if algorithm to count the number of values that are either less than 3 or more than 8. You must add the parameters to the function call to make it work. Note that the bigOrSmall function is provided to make the decision of if a number meets the criteria - part of what you pass to the count_if function should be that function. Note that running this code on your own computer is likely to produce a different random sequence than the one generated by CPPLab. That should not affect your code, just don't be surprised if that happens.

#include #include #include #include #include

using namespace std;

bool bigOrSmall(int x) { return x < 3 || x > 8; }

int main() { //Fill vector with random numbers 1-10 int seed; cin >> seed; srand(seed);

vector vec; for(int i = 0; i <= 10; i++) { vec.push_back( rand() % 10 + 1); }

//Print the vector for(int i : vec) cout << i << " "; cout << endl;

//count big and small values auto count = count_if( //start of function call //Do not modify anything on or above the line below this //YOUR_CODE_BELOW

//Your parameters to the function - OK that they are on a different line! // Function call already has ( and )... ONLY provide the parameters seperated by commas

//YOUR_CODE_ABOVE //Do not modify anything on or below the line above this

); //end of parameters for count_if

cout << count; }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!