To manipulate the stream to print in hexadecimal use the hex
manipulator:
cout << hex << a;
By default the hexadecimal characters are output in lowercase. To change it to uppercase use the uppercase
manipulator:
cout << hex << uppercase << a;
To later change the output back to lowercase, use the nouppercase
manipulator:
cout << nouppercase << b;