An algorithm that reads a sequence of positive numbers until a number divisible by 3 is reached

Hey guys, I just enrolled in a C++ class mid-semester and know absolutely nothing. My teacher said I can catch up with the others in my class, but it requires extensive research and studying. It would be awesome if you guys could help me and explain some of the stuff in the code. I know how to initiate the algorithm, but I have no clue how to use vectors and conditions.

The algorithm should read a sequence of positive numbers until a number divisible by three is reached.

1
2
3
4
5
6
7
8
9
#include <iostream>
using namespace std;
int main ()

{
//I hope it's right this far. I have no clue how to use conditions and vectors. Please help!


}
Last edited on
Start by the extensive studying. Read http://www.cplusplus.com/doc/tutorial/
Particularly http://www.cplusplus.com/doc/tutorial/basic_io/ and http://www.cplusplus.com/doc/tutorial/control/

It should create a field of the read positive couple numbers and show the vector used.

That you have to explain.
Thank you for the links :)
I think it means it should show the numbers given by the user that are couple if any are.
Last edited on
My teacher said I can ignore that part of the problem if I don't understand it, so I guess it doesn't matter.
Last edited on
What are "couple numbers"? Even numbers?

If a number is divisible by 2, then it is even. Both "divisible by 2" and "divisible by 3" can be determined with modulus operator (%).
https://stackoverflow.com/questions/17524673/understanding-the-modulus-operator

You apparently have to first read values and store them into vector.
See: http://www.cplusplus.com/reference/vector/vector/push_back/

Topic archived. No new replies allowed.