// Program: show_in_hex // Author: B. Massingill // Purpose: display internal representation of an integer. // Input: an integer n, from standard input (program will prompt for it). // Output: internal hexadecimal representation of n. #include #include // has setw(), setfill() #include // has EXIT_SUCCESS int main(void) { int n; // prompt for and read an integer. cout << "Enter an integer:\n"; cin >> n; // echo it back in regular decimal format. cout << "You entered " << n << endl; // now print it in hexadecimal format, exactly 8 digits cout << "The computer's representation is " << setw(8) << setfill('0') << hex << n << endl; return EXIT_SUCCESS; }