KARAKTER
ESCAPE
|
ARTI
|
\a
|
Bunyi bel (speaker
komputer)
|
\b
|
Mundur satu spasi
(backspace)
|
\f
|
Ganti halaman (form
feed)
|
\n
|
Ganti baris baru
(new line)
|
\r
|
Ke kolom pertama
baris yang sama (carriage return)
|
\t
|
Tab horizontal
|
\v
|
Tab vertical
|
\0
|
Nilai kosong (NULL)
|
\’
|
Karakter petik
tunggal
|
\”
|
Karakter petik
ganda
|
\\
|
Garis miring
terbalik (backslash)
|
\?
|
Karakter tanda
tanya
|
\DDD
|
Menyatakan sebuah karakter yang nilai ASCII nya sama dengan nilai octal
DDD
|
\xHH
|
Menyatakan sebuah karakter yang nilai ASCII nya sama dengan nilai
heksadesimal HH
|
\ddd
|
An octal character code. The numeric
code is 3 octal digits.
|
\xdd
|
A hex character code. All trailing
hex digits are combined.
|
Kode
format
|
Kegunaan
|
%c
|
Menampilkan sebuah
karakter
|
%s
|
Menampilkan nilai
string
|
%d
|
Menampilkan nilai
decimal integer
|
%i
|
Menampilkan nilai
decimal integer
|
%u
|
Menampilkan nilai decimal integer tdk bertanda (unsigned integer)
|
%ld
|
Menampilkan nilai decimal long integer
|
%lu
|
Menampilkan nilai decimal long integer tak bertanda
|
%li
|
Menampilkan nilai decimal long integer
|
%hu
|
Menampilkan nilai decimal short integer tak bertanda
|
%hi
|
Menampilkan nilai decimal short integer
|
%x
|
Menampilkan nilai heksa decimal integer
|
%o
|
Menampilkan nilai
okta integer
|
%f
|
Menampilkan nilai
pecahan / float
|
%e
|
Menampilkan nilai
float scientific
|
%g
|
Sebagai pengganti %f
atau %e tergantung yang terpendek
|
%lf
|
Menampilkan nilai
pecahan double
|
%le
|
Menampilkan nilai
pecahan double
|
%lg
|
Menampilkan nilai
pecahan double
|
%p
|
Menampilkan suatu
alamat memory untuk pointer
|
OPERATOR
|
KETERANGAN
|
CONTOH
|
+
|
Penjumlahan
|
2 + 3 Ã 5
|
-
|
Pengurangan
|
5 – 3 Ã 2
|
*
|
Pengalian
|
5 * 2 Ã 10
|
/
|
Pembagian
|
15 / 3 Ã 5
|
%
|
Sisa pembagi
(modulus)
|
8 % 3 Ã 2
|
=
|
A = B + C
|
Nilai A merupakan hasil dari pengerjaan B + C
|
+=
|
A += 1
|
A = A + 1
|
-=
|
A -= B
|
A = A – B
|
*=
|
A *= B
|
A = A * B
|
/=
|
B /= A
|
B = B / A
|
%=
|
B %= 2
|
B = B % 2
|
Operator
|
Meaning of Operator
|
Example
|
==
|
Equal to
|
5==3 returns false (0)
|
>
|
Greater than
|
5>3 returns true (1)
|
<
|
Less than
|
5<3 returns false (0)
|
!=
|
Not equal to
|
5!=3 returns true(1)
|
>=
|
Greater than or equal to
|
5>=3 returns true (1)
|
<=
|
Less than or equal to
|
5<=3 return false (0)
|
Operator
|
Jenjang
|
Fungsi
|
<<
|
5
|
Pergeseran bit ke kiri
|
>>
|
5
|
Pegeseran bit ke kanan
|
&
|
8
|
Bitwise AND
|
^
|
9
|
Bitwise XOR (Exclusive OR)
|
│
|
10
|
Bitwise OR
|
~
|
-
|
Bitwise NOT
|
S.no
|
Operator type
|
Operator
|
Description
|
1
|
Pre increment
|
++i
|
Value of i is incremented before
assigning it to variable i.
|
2
|
Post-increment
|
i++
|
Value of i is incremented after assigning
it to variable i.
|
3
|
Pre decrement
|
– –i
|
Value of i is decremented before
assigning it to variable i.
|
4
|
Post_decrement
|
i– –
|
Value of i is decremented after
assigning it to variable i.
|
Operator
|
Meaning of Operator
|
Example
|
&&
|
Logial AND
|
If c=5 and d=2 then,((c==5) &&
(d>5)) returns false.
|
||
|
Logical OR
|
If c=5 and d=2
then, ((c==5) || (d>5)) returns true.
|
!
|
Logical NOT
|
If c=5 then, !(c==5) returns false.
|
Level
|
Operator
|
Description
|
Grouping
|
1
|
::
|
scope
|
Left-to-right
|
2
|
() [] . -> ++ -- dynamic_cast static_cast reinterpret_cast
const_cast typeid
|
postfix
|
Left-to-right
|
3
|
++ -- ~ ! sizeof new delete
|
unary (prefix)
|
Right-to-left
|
* &
|
indirection and reference (pointers)
|
||
+ -
|
unary sign operator
|
||
4
|
(type)
|
type casting
|
Right-to-left
|
5
|
.* ->*
|
pointer-to-member
|
Left-to-right
|
6
|
* / %
|
multiplicative
|
Left-to-right
|
7
|
+ -
|
additive
|
Left-to-right
|
8
|
<< >>
|
shift
|
Left-to-right
|
9
|
< > <= >=
|
relational
|
Left-to-right
|
10
|
== !=
|
equality
|
Left-to-right
|
11
|
&
|
bitwise AND
|
Left-to-right
|
12
|
^
|
bitwise XOR
|
Left-to-right
|
13
|
|
|
bitwise OR
|
Left-to-right
|
14
|
&&
|
logical AND
|
Left-to-right
|
15
|
||
|
logical OR
|
Left-to-right
|
16
|
?:
|
conditional
|
Right-to-left
|
17
|
= *= /= %= += -= >>= <<= &= ^= |=
|
assignment
|
Right-to-left
|
18
|
,
|
comma
|
Left-to-right
|
0 komentar:
Posting Komentar