Uploaded by Nurazlan Shah

Arithmetic Expressions

advertisement
Arithmetic Expressions
4.1
Line #
I
j
k
Init
5
3
0
8
0
3
3
9
5
4
20
10
5
3
15
11
0
4
4
12
5
3
15
13
5
3
7
4.2
Expressions
( x + 23 ) / y
Relational expression or Arithmetic
expression?
Arithmetic expression
y > ( x % 2 )
Relational expression
wage + overtime * 0.05
Arithmetic expression
energy == ( 0.5* mass * mass)
Arithmetic expression
( x < z * w + 5 )
Relational expression
4.3
Relational Expressions
Value
y > x
1
y < 2
0
x >= 3
1
y <= x
0
x == 5
1
y != 6
0
4.4
Boolean Expressions
( y > 10) && ( z <= x )
Value
0
( z <= y) && ( x == 4)
0
( y != z) && ( z < x )
0
( z >= y ) && ( x != 3)
1
( y > 10) || ( z <= x )
0
( z <= y) || ( x == 4)
1
( y != z) || ( z < x )
1
( z >= y ) || ( x != 3 )
1
4.5
int y = 0, z =
10;
printf(“%d”, y >
z)
Output : 0
int y =0, z = 10;
printf(“%d”,
(y>z)+10)
int y = 0, z = 10;
printf(“%d”,(y>z)*10);
Output : 10
Output : 0
Download