Chapter 2 Notes
Chapter 2 Notes
Chapter 2 Notes
Types
VALID INVALID
int a = 22 ; int a = 22 ;
int b = a; int b = a;
int c = b + 1; int c = b + 2;
int d = 1 , e; int d = 2 , e;
int a,b,c;
int a,b,c = 1 ;
a = b = c = 1;
Arithmetic Instructions
a+b
Operand 1 Operand 2
Operator
3%2=1
-3 % 2 = -1
Arithmetic Instructions
Type Conversion
*, / , x = 4 + 9 * 10
%
+, -
= x=4*3/ 6*2
Arithmetic Instructions
Associativity (for same precedence)
Left to Right
x=4*3/ 6*2
Instructions
Control Instructions
Used to determine flow of program
a. Sequence Control
b. Decision Control
c. Loop Control
d. Case Control
Operators
a. Arithmetic Operators
b. Relational Operators
c. Logical Operators
d. Bitwise Operators
e. Assignment Operators
f. Ternary Operator
Operators
Relational Operators
==
>, >=
<, <=
!=
Operators
Logical Operators
&& AND
|| OR
! NOT
Operator Precendence
Priority Operator
1 !
2 *, / ,
%
3 +, -
5 ==, !=
6 &
&
7 ||
8 =
Operators
Assignment Operators
=
+=
-=
*=
/=
%=