Kamis, 07 Juli 2011

Manipulator C++

#include<iostream.h>
#include<iomanip.h>


void main()
{
int a,b; //klo mw masukin desimal,,pake float

cout << "Masukkan 2 angka : ";
cin >> a >> b;

cout << "a : " << setiosflags(ios::left) << setw(5) << setfill('*') << a << endl;
cout << "b : " << setiosflags(ios::left) << setw(8) << setfill('#') << b << endl;

cout << "a dalam hex : " << setiosflags(ios::uppercase) << hex << a << endl; //sama aj kyk pake setiosflags(ios::hex)
cout << "b dalam hex : " << setiosflags(ios::uppercase) << hex << b << endl;

cout << "a dalam oct : " << oct << a << endl; //sama aj kyk pake setiosflags(ios:: oct) tp tnpa spasi yah,,
cout << "b dalam oct : " << oct << b << endl;

cout << setiosflags(ios::showbase | ios::uppercase );
cout << "base hex a : " << hex << a << endl;
cout << "base hex b : " << hex << b << endl;
cout << "base oct a : " << oct << a << endl;
cout << "base oct b : " << oct << b << endl;
cout << resetiosflags(ios::showbase | ios::uppercase );

cout << setiosflags(ios::fixed); //notasi desimal
cout << "desimal a : " << a << endl;
cout << "desimal b : " << b << endl;
cout << resetiosflags(ios::fixed);

cout << setiosflags(ios::scientific); //notasi exponensial
cout << "exponensial a : " << a << endl;
cout << "exponensial b : " << b << endl;

float c = 5.45789;
cout << "c : " << setprecision(3) << c << endl;
cout << "exponensial c : " << setiosflags(ios::scientific)<< c << endl;
cout << "desimal c : " << setiosflags(ios::fixed) << c << endl;


cin.get();
cin.get();
}




sumber : http://www.kaskus.us/showthread.php?t=1215259&page=7

Tidak ada komentar:

Posting Komentar

Jangan Lupa Kasih Komentar Dan masukannya ya