Popular Google Pages:
◕ Bengali Story writing competition. More..
This article is regarding How to display a value in Hexadecimal form in C++?
Last updated on: 06th December 2016.
◕ how to display a value in Hexadecimal form in C++?
- If we want to display a value in hexadecimal form we have to use some special features of cout. For an example, the iostream header file provides the endl manipulator to give cout the message to start a new line. Similarly, it provides the hex manipulators to give cout the messages to display integers in hexadecimal form.
■ The example is given bellow.
Let we have a program like this:
using namespace std;
int street = 13; // this is in Decimal form
cout << hex;
cout << "Displaying Decimal in Hexadecimal form: " << street << endl;
The output is:
Displaying Decimal in Hexadecimal form: d
The code cout << hex; doesn’t display anything onscreen. Instead, it changes how the cout will display the integers in Hexadecimal. This hex is a Manipulator. This manipulator gives a message to cout which tells it how to behave with the integer.
How to display a value in Hexadecimal form in C++?
How to display a value in Octal form in C++?
How C++ identify the base of a number?
Top of the page