Using Modulus operator?

I feel like I am making this problem way more complicated than it should be. All I'm trying to do is print out the numbers that are below 1000 that are divisible by 3 or 5.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include <iostream>
#include <cmath>
using namespace std;

int main()
{

	int number = 1000;
	int x = 1;

	cout << "Calculating all of the numbers below 1000 that are divisible by 3 and 5...";


	while (x <= 1000)
		{
			if (x % number == 0)
			{
				cout << (x / number) << endl;
				x++;
			}

			else 
			{
				x++;
			}
		}

	return 0;
}
Last edited on
where do you check to see if it's divisible by 3 or 5 ?

you also have a ; that is not needed in line 11 and 14
Last edited on
Topic archived. No new replies allowed.