12.07.2015 Views

MODUL PRAKTIKUM C ++ - iLab - Universitas Gunadarma

MODUL PRAKTIKUM C ++ - iLab - Universitas Gunadarma

MODUL PRAKTIKUM C ++ - iLab - Universitas Gunadarma

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Modul C<strong>++</strong>Contoh diatas, mengkonversikan nilai 3.14 menjadi nilai integer (3). Type castingoperator yang digunakan (int). Cara lainnya :i = int ( f );sizeof()Operator ini menerma 1 parameter, dapat berupa type variabel atau variabel itu sendiridan mengembalikan ukurannya type atau object tersebut dalam bytes :a = sizeof (char);Contoh diatas akan memberikan nilai 1ke a karena char adalah tipe data denganpanjang 1 byte. Nilai yang diberikan oleh sizeof bersifat konstsn constant.Prioritas pada operatorContoh :a = 5 + 7 % 2Jawaban dari contoh diatas adalah 6. Dibawah ini adalah prioritas operator dari tinggi kerendah :Priority Operator Description Associativity1 :: scope Left23() [ ] -> .sizeof<strong>++</strong> -- increment/decrement~ Complement to one (bitwise)! unary NOT& *(type)Reference and Dereference(pointers)Type casting+ - Unary less signLeftRight4 * / % arithmetical operations Left5 + - arithmetical operations Left6 > bit shifting (bitwise) Left7 < >= Relational operators Left8 == != Relational operators Left9 & ^ | Bitwise operators Left10 && || Logic operators Left11 ?: Conditional RightLaboratorium Sistem Informasi <strong>Universitas</strong> <strong>Gunadarma</strong>

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!