Oct and hex manipulators are used for conversions to octal and hexadecimal - C++ Language Basics

C++ examples for Language Basics:Console

Description

Oct and hex manipulators are used for conversions to octal and hexadecimal

Demo Code

#include <iostream>
#include <iomanip>
using namespace std;
int main()// ww w.  j a v  a2  s  . c  o m
{
   cout << "The decimal (base 10) value of 15 is " << 15 << endl;
   cout << "The octal (base 8) value of 15 is " << showbase << oct << 15 <<endl;
   cout << "The hexadecimal (base 16) value of 15 is " << showbase << hex << 15 << endl;
   return 0;
}

Result


Related Tutorials