Write with Vector in c++ | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
- 3

Write with Vector in c++

Write a program that get some numbers from user If user input O ,print Odd numbers when user input E , print even numbers We should write it with vector in c++

28th May 2020, 11:26 AM
Leda
3 Answers
0
What is the question? Show the code you wrote and what your problems are. It's unlikely that someone will do your homework.
28th May 2020, 5:35 PM
Michi
Michi - avatar
0
I wrote it but I don’t know how to get number from user with vector??
28th May 2020, 6:04 PM
Leda
0
To get numbers from the user (cin) you can use int i; std::cin >> i; To read several numbers into a vector you could use int i; std::vector<int> v; while (std::cin >> i) { v.push_back(i); } This will read numbers (and push them into the vector) until the end of the input or something is encountered, which is not a number (then the failbit is set, reset it, if you want to read from the input again)
28th May 2020, 6:39 PM
Michi
Michi - avatar