Making I/O in Octal Format : int output « Data Type « C++






Making I/O in Octal Format

   
#include <iomanip>
#include <iostream>

using namespace std; 

int main( )
{
   cout << "Enter an octal number: ";
   int num;
   cin >> oct >> num;

   // Display number in decimal and octal
   cout  << "Decimal: " << num << "\tOctal: " << oct << num
         << "\tOctal with base: " << showbase << num << endl;
}
  
    
    
  








Related examples in the same category

1.Decimal in hexadecimal
2.Decimal in octal
3.Decimal in decimal
4.Display decimal value as hexadecimal value
5.Display decimal value as Octal value
6.Output integer with different base: 8, 10, 16
7.Right justification
8.Left justification
9.Use .(dot) as place holder
10.Set width of output
11.Using hex, oct, dec and setbase stream manipulators.
12.Printing an integer with internal spacing and forcing the plus sign.
13.Set showpos flag for decimal