Question: Traversing a vector to find the max ( or min ) is common. Given a vector of integers, output the maximum integer found in the

Traversing a vector to find the max (or min ) is common. Given a vector of integers, output the maximum integer found in the vector. If the input is 43826, the output is 8.
Hints:
- Declare a variable named maxitem to hold the max value seen so far. Update that value if you ever see a larger value.
- Initialize that variable to any element's value, NOT to 0.
main.cpp
```
#include
#include
using namespace std;
int main(){
int numItems;
vector listItems;
int currItem;
int i;
// Get items
cin >> numItems;
for (i =0; i numItems; ++i){
cin \gg> currItem;
listItems.push_back(currItem);
}
/* Type your code here */
```
Traversing a vector to find the max ( or min ) is

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 Programming Questions!