Operator C/C++ P1

Ada banyak operator yang digunakan dalam pemrograman bahasa C/C++ antara lain:


1. Arithmetic operators
2. Increment/decrement operators, and side effects
3. Sizeof, comma, and arithmetic if operators
4. Relational operators (comparisons)
5. Logical operators
6. Converting between binary and decimal
7. Bitwise operators

1. Arithmetic operators 

a. Unary arithmetic operators
Ada 2 jenis Unary arithmetic operators, plus(+) dan minus (-). Unary operator hanyamempunyai satu operand.

Contoh:
+5 = 5, dan +x = x
 jika x = 5, maka -x = -5
x = 5 - -3 --> tanda minus yang pertama adalah operator pengurangan dan yang kedua adalah unary minus operator

b. Binary arithmetic operators
Ada 5 binary arithmetic operators. Binary operators adalah operator yang terletakan pada kiri dan kanan operand

c. Arithmetic assignment operators
Catatan:
 x = x + y dapat juga ditulis --> x += y
 x = x * 5, dapat juga ditulis --> x *= 5

bersambung....

0 komentar:

Posting Komentar

Followers

Total dilihat

Diberdayakan oleh Blogger.

online log book

Cari Blog Ini