Question: Integer numIn is read from input. Given the integer vector hourlyTemps with the size of numIn, write a for loop that sets sumOdds to the

Integer numIn is read from input. Given the integer vector hourlyTemps with the size of numIn, write a for loop that sets sumOdds to the sum of all the odd integers in hourlyTemps

Ex:

If the input is 5 108 118 137 147 160

then the output is:

sumOdds: 284

#include

#include

using namespace std;

int main() {

vector hourlyTemps;

unsigned int i;

int numIn;

int sumOdds;

cin >> numIn;

// Creates a vector of size numIn and initialize all values to 0

hourlyTemps.resize(numIn);

for (i = 0; i < hourlyTemps.size(); ++i) {

cin >> hourlyTemps.at(i);

}

''YOUR CODE GOES HERE!''

cout << "sumOdds: " << sumOdds << endl;

return 0;

}

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!