Question: Read ints from cin and store values into nums until you see a 0 (do not store the 0). Then print the middle value you

Read ints from cin and store values into nums until you see a 0 (do not store the 0). Then print the middle value you read in (will always be an odd number of values). Hint: you should be making use of push_back(val) and size()

#include #include

using namespace std;

template void print(const vector& v) { for (auto myIt = v.begin(); myIt != v.end(); ++myIt) { cout << *myIt << " "; } cout << endl; }

int main() { vector nums;

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

int num; cin >> num; while(num != 0) { //add to the vector cin >> num; } //print middle item

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

}

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!