Convert to hex:
cout << hex << int(x) << endl;
How to convert conversely, from hex to dec?
Enter hex number simple:
cin >> hex >> x;
Convert to hex:
cout << hex << int(x) << endl;
How to convert conversely, from hex to dec?
Enter hex number simple:
cin >> hex >> x;
 
    
     
    
    You can use the std::dec IO manipulator:
std::cout << std::dec << int(x) << endl;
Note that this is only necessary if you have previously used std::hex or other means to manipulate the base of std::cout. Otherwise you need take no action: the default for an int is decimal.
 
    
    Don't use the std::hex manipulator?
std::cout << int(x) << std::endl;
