Search This Blog

To convert the base of one numeric value to another base

#include<iostream.h>
#include<conio.h>
void main()
{
cout<<"Decimal value of 12 is:"<<setbase(dec)<<12<<endl;
cout<<"Octal value of 12 is:"<<setbase(oct)<<12<<endl;
cout<<"Hexa decimal of 12 is:"<<setbase(hex)<<12<<endl;
}

output:
Decimal value of 12 is: 12
Octal value of 12 is: 14
Hexa decimal of 12 is: c

No comments:

Post a Comment