I am new to c++ and find a lots of difficulties on learning it.
How to read a list of number input by user? Do i need to cin >>x , y ,z ....e.t.c?
And how to let the programme to read the numbers and find out which are even and finally adding them together????
thanks!
cin >> x >> y >> z >> etc would do, but you'd have to do exactly the same number of inputs each time.
Instead, make a vector of int values:
vector<int> inputStore;
and then loop until you're done taking inputs
1 2 3 4 5 6 7 8
while (not_finished_taking_inputs)
{
// CODE HERE to decide when finished taking inputs
int temporary;
cin >> temporary;
inputStore.push_back(temporary);
}
Then, you can loop over the vector, summing only the even numbers.