Remarks
Manipulators are used in the stream to alter the formatting of the stream.
A reference to an object of type ios_base is returned to the stream. (The this pointer.)
Floatfield manipulators
Manipulator
Definition
ios_base& fixed(ios_base&)
format in fixed point notation
ios_base& scientific(ios_base&)
use scientific notation
#include <iostream>
#include <iomanip>
int main()
{
using namespace std;
long number = 64;
cout << "Original Number is "
<< number << "\n\n";
cout << showbase;
cout << setw(30) << "Hexadecimal :"
<< hex << setw(10) << right
<< number <<'\n';
cout << setw(30) << "Octal :" << oct
<< setw(10) << left
<< number <<'\n';
cout << setw(30) << "Decimal :" << dec
<< setw(10) << right
<< number << endl;
return 0;
}
Result:
Original Number is 64
Hexadecimal : 0x40
Octal :0100
Decimal : 64