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>( (5 == 5) && (3 > 6) ) returns false ( true &&false ).( (5 == 5) || (3 > 6)) returns true ( true ||false ).Conditional operator ( ? ).operator kondisional mengevaluasi ekspresi dan memberikan hasil tergantung dari hasilevaluasi (true atau false). Sintaks :condition ? result1 : result2Jika kondisi true maka akan menghasilkan result1, jika tidak akan menghasilkanresult2.7==5 ? 4 : 3 returns 3 since 7 is not equal to 5.7==5+2 ? 4 : 3 returns 4 since 7 is equal to 5+2.5>3 ? a : b returns a, since 5 is greater than 3.a>b ? a : b returns the greater one, a or b.Bitwise Operators ( &, |, ^, ~, ).Operator Bitwise memodifikasi variabel menurut bit yang merepresentasikan nilai yangdisimpan, atau dengan kata lain dalam representasi binary.opasm Description& AND Logical AND| OR Logical OR^XOR Logical exclusive OR~ NOT> SHR Shift RightExplicit type casting operatorsType casting operators memungkinkan untuk mengkonversikan tipe data yang sudahdiberikan ke tipe data yang lain. Ada beberapa cara yang dapat dilakukan dalam C<strong>++</strong>,yang paling popular yaitu tipe baru dituliskan dalam tanda kurung () contoh :int i;float f = 3.14;i = (int) f;Laboratorium 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!