C++, Vector

need to create a program that accepts an unknown number of integer values which then gets stored in a vector. When the user inputs “enough” then the program will output all the odd numbers in the integer list given by the user. the vector is checked in a while loop with a nested if. i got the concept but can't find a way to build the code for it.


the program has to work something like this.

input a number: 212
input a number: 2031
input a number: 13
input a number: 22
input a number: enough

list of odd numbers are:
2031
13

Press a key to exit the program…

how to do this?
one way is as follows:
1
2
3
4
5
6
7
8
9
10
11
int x=0,count=0;
cout << "input a number:" << endl;
while (cin >> x) {   // checks if entered value is an integer
  if (x % 2) {          // if x is odd
    // add x to vector;
    count++
  }
  cout << "input a number:" << endl;
}
for (int i=0;i<count;i++)
  print the vector element values;
has few errors.
when the user inputs "enough" the program has to output the odd numbers.
Topic archived. No new replies allowed.