ch2-Numconv (Decimal to octal and hex)
Chapter_2 Exercise_2-1 Concat | Exercise_2-2 |
Numconv.cpp TCP1, p. 107 download
// Converts decimal to octal and hex
#include <iostream>
using std::cout;
using std::cin;
using std::endl;
using std::oct;
using std::hex;
int main()
{
int number;
cout << "Enter a decimal number: ";
cin >> number;
cout << "value in octal = 0" << oct << number << endl;
cout << "value in hex = 0x" << hex << number << endl;
}
/*
g++ Numconv.cpp -o Numconv
./Numconv
Enter a decimal number: 15
value in octal = 017
value in hex = 0xf
*/
Chapter_2 Exercise_2-1 Concat | BACK_TO_TOP | Exercise_2-2 |
Comments
Post a Comment