Displaying all the numbers made by 2 digits in ascending order

The title says it all.
So the program should display 12, 13, 15, 16, 17, 18 ,19, 23, 24, 25, ..... , 89.

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 n, i;
    for(i=10;i<=100;i++)
    {
        n=i%10;
        i=i/10;
        if(n>i)
        {
            i=i*10+n;
            cout<<i<<" "<<n;
        }
    }
    return 0;
}

It actually doesn't work as needed. It doesn't even stop, it just displays some numbers..
1
2
3
for( int first = 1 ; first < 10 ; ++first ) // first digit
    for( int second = first+1 ; second < 10 ; ++second ) // second digit (> first digit)
        std::cout << first << second << " (" << first*10 + second << ")\n" ;
Topic archived. No new replies allowed.