2. • Declaration:
int x;
↙ ↘
data type identifier name
(for more than one variables separate them with commas)
• Initialization:
x=9;
(value is stored )
3. • Declaration & initialization in one step:
int x=9;
• = is an assignment operator
Int x,y=6,z=2;
x=y; ////x=6
y=z; ///y=2
z=x; ///z=6
4. • Its associativity is right (it means right side of =(assignment
operator )is evaluated first.)
Keywords/reserve words:
• Lower case letters
• E.g for,while,int,char,float
Variable:
• It can be modified. they are used to store constant values
• int→2 bytes e.g 1,2,3 etc
• float → 4 bytes e.g 1.1,2.3 etc
• char →1 byte e.g A,S,D, 1 ,2,3, +,*,& etc
6. Operators
• Is anything that perform some action on some variable or constant
1.Unary operators
2.Binary operators
3.Arithmatic operators
1.Unary operators:
++, -- ,+ , -
They increment the value by 1.
(a)Unary minus operator:-
It is used to reverse the sign of a value.it makes a +ve value to –ve value and
vice versa.e.g
int a, b;
a=87;
b=-a;
It has higher precedence over binary operator.
8. (B) postfix decrement:
b=a--
b=a
a=a-1
2.Binary operators:
• The operators that operate on two data items.
• E.g multiplication etc
3.Arithmatic operators: +, - ,* ,/ , %
• Remainder operator :modulus
9. Order of precedence
• * , / ………………….left to right
• + , - ………………….left to right
• ( ) parenthesis ………………….left to right
• Parenthesis within parenthesis(innermost first)
• 1+2+3-4+5
• 7+c*d/c
• a/b/c
• 2+a/b*5
• 6+12/6*2-1
10. Type casting:
Conversion of one data type of numeric value to
another
1.Implicit type casting
2.Explicit type casting
Arithmatic expressions:
2(a+b) →2*(a+b)
5/9(F-32) →5/9*(F-32)
14. Conditional operator:
• It consists of “?” and “:”.
• Its syntax is
{condition}?{exp1}:{exp2}
Where
Condition…..represents test condition
Exp1 & exp2….represents two expressions which
may be arithmetic expression or constant value.