twitter
    Find out what I'm doing, Follow Me :)

Lab ke2

Ini codingan lab pertemuan ke2 (dengan sedikit perubahan oleh saya)

#include
#include

void main(){
/*
//cout.setf(ios::hex); hexadesimal untuk angka dibawahnya

cout.setf(ios::oct); //octal untuk angka dibawahnya
cout << 123 << endl;

atau

cout << oct << 123 << endl;

//cout.setf(ios::dec);
cout.unsetf(ios::oct); //untuk mengembalikan dari octal
cout << 123 << endl;
cout.setf(ios::showbase); //menampilkan base bilangan
hexa 0xff
octal 0123
cout.setf(ios::uppercase); //hurufbesar untuk hexa
*/

cout.fill('.'); //isi dengan "."
//cout.width(10); //sama dengan setw(10);
cout.setf(ios::left); //rata kiri
cout << setw(10) << "halo" << endl; //geser kanan +iomanip.h
cout.setf(ios::right); //rata kanan
cout << setw(10) << "apa" << endl;
cout.fill(' '); //isi dengan " "
cout << setw(10) << "kabar" << endl;

cout.setf(ios::showpos); //menampilkan tanda positif
cout.setf(ios::internal); //kasi spasi antar tanda +
//gabungin ios -> cout.setf( | );
cout <
cout << setprecision(5); //decimal seperti %.2f
cout.setf(ios::fixed);
cout << 123.456 << endl;

//cout.setf(ios::scientific); //decimal pangkat 10



cin.get();
}

0 comments: