Modulus operator question

I am trying to see if all the numbers below 1000 are divisible by 3 or 5, however when I execute the program, it just sits there and blinks at me and nothing is printed out to the screen.

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
30
31
32
33
34
35
36
37
38
#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 % 3) == 0)
			{
				cout << x << " is divisible by 3" << endl;
				x++;
			}
		

			else if ((x % 5) == 0)
			{
			    cout << x << " is divisible by 5" << endl;
				x++;
			}
			
			else
			{
			    cout << x << " is not divisible by 3 nor 5";
			    x++;
			}
		
		}

	return 0;
}
The program is correct.
It must be the compiler I am using, thank you.
Line 31: you forgot a newline.

4 is not divisible by 3 nor 55 is divisible by 5

I laughed. :O)
hahahaha I totally noticed that after I posted it xD
Topic archived. No new replies allowed.