#include <iostream>
usingnamespace std;
int main()
{
int a, b, c;
cout << "Enter two integers ";
cin >> a >> b;
cout << endl;
while (a > b)
{
cout << "The first number must "
<< "be smaller than the second.";
cout << "Enter two integers ";
cin >> a >> b;
cout << endl;
}
while ((a = a) && (a < b))
{
a = a + 2;
cout << a << endl;
}
c = a + a;
cout << c << endl;
return 0;
}
If your question is: "From a list of integers (numbers), how do you find the sum of all the even numbers and the sum of all the odd numbers respectively?"
Then, here is how:
1) Store the numbers in a vector<int>
2) Use the % (modulo) operator to figure out if the number is odd or even
3) Put the odd numbers in another vector<int>. Put the even numbers in another vector<int>
4) Create a int variable for each vector to store the sum of each vector's elements.
Literally all that's left is to store the sum of each vector in it's respective sum variable