Consider your boundary conditions. For each digit, unless the next outer loop is on the last iteration, you want to print 0 through 9. Otherwise you print 0 through the digit value. There isn't a very clean solution; you either use conditional expressions or long and redundant if sequences:
#include <iostream>
using namespace std;
int main()
{
int a, b, c;
int number;
cout<<"Enter a number from 0 - 999: ";
cin>> number;
a = number / 100;
b = (number % 100 - number % 10) / 10;
c = number % 10;
for ( int i = 0; i <= a; i++ ) {
for ( int j = 0; j <= ( ( i == a ) ? b : 9 ); j++ ) {
for ( int k = 0; k <= ( ( j == b ) ? c : 9 ); k++ )
cout<< i << j << k <<endl;
}
}
}
Narue
Bad Cop
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401