cout not printing anything?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <iostream>
using namespace std;

int main () {
    for (int x=1;x>9;x++) {
        for (int y=1;y>9;y++) {
            cout << x;
            cout << " x ";
            cout << y;
            cout << " = ";
            cout << x*y;
            cout << endl;
        }
    }
    return 0;
}

so basically this code should output the multiplication table like this:
1
2
3
4
5
6
7
8
9
1 x 1 = 1
1 x 2 = 2
1 x 3 = 3
....
2 x 1 = 2
2 x 2 = 4
2 x 3 = 6
....
9 x 9 = 81


the problem is, cout is just not outputting anything.. I don't know what's happening, never happend before, probably it's something basic I'm blind and I can't see.
line 5 is the problem, x is never greater than 9
no, I doubt it's the problem, since if I write something in the console I can see it which means it stopped running. also why wouldn't it?
line 5 is the problem, x is never greater than 9


This.
I don't understand your last question. I repeat what I said before, but a little bit more in depth:

 
for (int x=1;x>9;x++)


the program will never enter the for loop, because the conidition is "as long as x is grater than 9". x is initialized as 1, so... it just doesn't fit the condition...

try instead:

 
for (int x=1;x < 9;x++)    // as long as x is less than 9 --> 1 2 3 4 5 6 7 and 8 will do 
wait I understood now.. I wrote the wrong sign. lol, thanks
To see nine multiplication tables, use:

 
for (int x=1;x <= 9;x++)    // as long as x is less or equal to 9 
Topic archived. No new replies allowed.