11
Data Format
12
13
Format Keluaran
14
Example:
15
LATIHAN:
------------------------------------------------------------------------
en
faktorial
fibonacci
----------------------------------------------------------------------1
.
..
..
2
.
..
..
.
..
..
10
.
..
..
-----------------------------------------------------------------------16
Scalar Operations
17
variable_name = expression;
addition
a+b
subtraction
a-b
multiplication
axb
division
a/b
exponent
ab
a+b
a-b
a*b
a/b
a^b
Scalar Operations
18
x=3*2+6/2
x = ?
Processing order of operations is important
parenthesis (starting from the innermost)
exponentials (left to right)
multiplications and divisions (left to right)
additions and subtractions (left to right)
x=3*2+6/2
x = 9
Operator Hierarchy
19
Relational Operators
Relational operators are used to represent
conditions
Result of the condition is either true or
false
false is represented by 0
true is represented by 1 (non-zero)
20
Relational Operators
Operation
Result
3<4
3 <= 4
3 == 4
3 ~= 4
3>4
4 >= 4
A < B
1
21
Relational Operators
Dont confuse equivalence (==) with
assignment (=)
Be careful about round off errors during
numeric comparisons (you can represent
x == y as abs(x-y) < eps)
Relational operations have lower priority
than arithmetic operations (use parentheses
to be safe, though)
22
Logical Operators
23
Logical Operators
input
a
b
and
a&b
or
a|b
xor
xor(a,b)
not
~a
24
Branching Examples
95
86
76
66
0
Grade
A
B
C
D
F
26
27
Hasil:
ii = 1
ii = 2
End of loop
Latihan
Prima genap
28
LATIHAN
29
LATIHAN
1.
2.
31