// two recursive functions that write the digits of a number vertically. #include // Provides cin, cout #include void write_vertical(unsigned int number) { if (number < 10) cout << number << endl; // Write the one digit else { write_vertical(number/10); // Write all but the last digit cout << number % 10 << endl; // Write the last digit } } void super_write_vertical(int number) { if (number < 0) { cout << '-' << endl; // print a negative sign super_write_vertical(abs(number)); // abs computes absolute value // This is Spot #1 referred to in the text. } else if (number < 10) cout << number << endl; // Write the one digit else { super_write_vertical(number/10); // Write all but the last digit // This is Spot #2 referred to in the text. cout << number % 10 << endl; // Write the last digit } } void main( ) { int i; cout << "Please type a non-negative number: "; cin >> i; cout << "The digits of that number are:" << endl; write_vertical(i); cout << "Please type a negative number: "; cin >> i; cout << "The digits of that number are:" << endl; super_write_vertical(i); cout << "Let's get vertical!" << endl; }