#include <iostream> using namespace std; void write_vertical(int n); int main() { int n; cout << "Recursion" << endl << "Enter a number with one or more digits: "; cin >> n; cout << "--------------------------------------" << endl; write_vertical(n); return 0; } void write_vertical(int n) { if (n < 10) { cout << n << endl; } else { write_vertical(n / 10); cout << (n % 10) << endl; } }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter