Class 9th
Chapter -5
OPERATORS: The operations are represented by operators and the object of the
operation are referred to as operand.
The different type of operators are
i) Arithmetical operators. ⅱ) Relational Operators. iii) Logical operators
iv) Bitwise operators. v) Increment Operators etc.
i) Arithmetic Operators: +,-,*,/,% are the main arithmetic operators.
ii) Increment/ decrement operators (++, - - ): These operators are unary operators
(work with only one operand). It can be divided into two pre increment / pre decrement
and post increment or pose decrement.
pre increment/pre decrement: It follows the rule of change - then - use i.e first they will
change the value then the new value will use.
Syntax: ++ variable name/ --variable name
Eg: int a = 10;
[Link](++ a); will result to 11 because first 10 will be increased to 11 and
new value 11 will be used for further operation.
int a = 10;
[Link] (- - a); will result to 9 because of the same reason.
post increment/post decrement: It follows the rule of use-then-change i.e first they will
use the old value then change into the new value
Syntax: variable name ++/ variable name - -
Eg: int a = 10;
[Link] ( a ++);
It will result to 10 because first 10 will be used and then changed to 11
Unary operators: operates on single [Link]. increment, decrement
operators,unary +, unary-,!.
Binary operators: operates on two operands, eg: Binary +, Binary-,*,-,.....
Ternary Operators: operates only on three operands Eg: conditional operator (?:)
iii) Relational Operators: It refers to the relationship that values can have with one
another. The six relational operators are <,<=,>,>=,== ,!=.The relational operators have
the lower precidence than the arithmetical operators.
Q) Find the output of the following segment
int a = 10, b = 7;
[Link]( a > b ); Output: true
[Link]( a! = b ); Output: true
[Link]( a < - b ); Output: false.
iv) Logical Operators: Relational operators often are used with logical operators for
checking more than one condition that is why logical operators are also called
conditional operators .The main logical operators are &&,||,!, &,|,^.
v) Assignment Operators: = is the only assignment operator but *=, %=, += , – =
,/=are called arithmetical assignment operators.
Note: The assignment operators are getting the least priority, so it will execute at the
last.
Conditional Operator (?:) It is a ternary operator. It requires three operand to work
with. it will work same as if else if will be represented by? and else with: Conditional
operators having the lowest precedence.
The general form is variable = expression 1? expression 2: expression 3;.
eg: a=x>0?5:7;
The result will be 5 when x >=1 to ……
The result will be 7 when x <=0,.......