#include //for cout and << #include using namespace std; void print(int n, int base = 10); //only one print function int main() { int i = 255; print(i, 10); print(i, 8); print(i, 16); print(i); return EXIT_SUCCESS; } void print(int n, int base) { if (base == 8) { cout << oct << n << "\n"; } else if (base == 10) { cout << dec << n << "\n"; } else if (base == 16) { cout << hex << n << "\n"; } else { cerr << "base " << base << " must be 8, 10, or 16\n"; exit(EXIT_FAILURE); } }