Not sure what the question is asking

So the code I have right now shows the counter going from 1-30 and at 30 it says that it has a multiple of 2, 3, and 5. But now I have to modify the problem so that the infinite loop meets these previous conditions, but in addition:
---The break can not happen if the counter is a multiple of 30
---Regardless of the logic involving multiples, the break can happen if the value of the counter is at least 3000.


If somebody can explain what it's asking and help me out I would appreciate it.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <iostream>

using namespace std;

int main()
{
	int counter = 0;

	do
	{
		counter += 1;
		cout << "current counter value " << counter << "\n";
	} 
	while (counter % 2 || counter % 3 || counter % 5);

	cout <<  "is a multiple of 2, 3, and 5\n";

	cin.get();
	return 0;
}



Also I have to make the .exe display show it like this:

....
...
...
current counter value:2998
current counter value 2999
current counter value 3000
current counter value 3001 is (a multiple of 2, 3, and 5, but not a multiple of 30) or (counter > 3000).
Last edited on

---Regardless of the logic involving multiples, the break can happen if the value of the counter is at least 3000.

It doesn't matter if counter is divisible by 2/3/5/30. As long as counter is over 3000, the loop will be broken.
Last edited on
You have additional tests, so there will be more OR (||) conditions.

You have currently some 'is multiple' tests - add a 'is not a multiple' test using a NOT (!) condition.

Given that what you write depends on your test, and the output will be within the loop, I would create a bool variable to work it out within the loop.
Topic archived. No new replies allowed.