// odometer program, nested loop example // Mikhail Nesterenko // 01/23/2012 #include using std::cout; using std::endl; using std::cin; int main(){ cout << "Input the number of miles to go [1-100]: "; int distance; cin >> distance; const int singles = distance % 10; const int tens = distance / 10; // nested loops // printing odometer values for the complete tens of distance // ex: for distance of 55, printing from 00 to 49 for (int i = 0; i < tens; ++i) // outer loop for (int j = 0; j < 10; ++j){ // inner loop cout << i; cout << j; cout << endl; } // printing remaining odo values // ex: for distance of 55, printig from 50 to 55 for (int i = 0; i <= singles; ++i) cout << tens << i << endl; }