Home   |   About   |   Terms   |   Contact    
Read & Learn
 

How to display a value in Octal form in C++?

C++

☯ All C++ Articles     ☯ All Articles


A new product.






Popular Google Pages:




This article is regarding How to display a value in Octal form in C++?
Last updated on: .

◕ How to display a value in Octal form in C++?

- If we want to display a value in Octal 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 oct manipulators to give cout the messages to display integers in Octal form.



■ The example is given bellow.

Let we have a program like this:

#include <iostream>
using namespace std;
int main(){
int road = 13; // this is in Decimal form
cout << oct;
cout << "Displaying Decimal in Octal form: " << road << endl;
return 0;
}

The output is:
Displaying Decimal in Octal form: 15



Please note:
The code cout << oct; doesn’t display anything onscreen. Instead, it changes how the cout will display the integers in Octal. This oct is a Manipulator. This manipulator gives a message to cout which tells it how to behave with the integer.


Related article:
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?



Popular Google Pages:



Top of the page

Amazon & Flipkart Special Products

   


Top of the page