There is a new breakthrough in C + + to convert a number into the form of Octal, Hexadecimal or Decimal. This time we use a manipulator named dec, oct, and hex. Third manipulator is useful for displaying data in decimal form (base number 10), octal (base bilangna 8), and hexadecimal (base 16 numbers).
oct convert to octal
convert to decimal dec
converting hex to hex
Example programs that demonstrate the use of three manipulators can be seen below:
#include <iostream.h>
#include <iomanip.h>
#include <conio.h>
void main()
{
int angka;
clrscr();
cout<<"PROGRAM KONVERSI NILAI"<<endl;
cout<<endl;
cout<<"Masukkan Angka yang Akan Dikonversi : "; cin>>angka;
cout<<endl;
cout<<"Hasil Konversi ke Oktal : "<<oct<<angka<<endl;
cout<<"Hasil Konversi ke Heksa : "<<hex<<angka<<endl;
cout<<"Hasil Konversi ke Decimal : "<<dec<<angka<<endl;
getch();
}
No comments:
Post a Comment