C++ Language: By:-Aakash Kaushik #9289817971, 98919893083
C++ Language: By:-Aakash Kaushik #9289817971, 98919893083
By:-AAKASH KAUSHIK
#9289817971, 98919893083
[email protected]
UNIT -4
OPERATORS &
EXPRESSIONS
compiler
to perform specific mathematical or
logical
manipulations.
operators operates on some data to give
results
For ex :- A+B=C
Here A, B are operands and + is the
operator which produces C as a result of
addition of A and B.
AAKASH KAUSHIK
9891983083,9289817971
CLASSIFICATION OF
OPERATORS
Based on the no. of operand needed for
operation operators can be broadly
classified into 3 categories.
UNARY OPERATORS
BINARY OPERATORS
TERNARY OPERATORS
AAKASH KAUSHIK
9891983083,9289817971
UNARY OPERATORS
The unary operators operate
on a single operand
INCREMENT/DECREMENT
OPERATOR
Increment operator increases integer value by one.
For ex.:int a=10;
a++; //will give 11
Decrement operator decreases integer value by
one.
For ex.:int a=10;
a--; //will give 9
AAKASH KAUSHIK
9891983083,9289817971
BINARY OPERATORS
The Binary operator takes 2
arguments.
AAKASH KAUSHIK
9891983083,9289817971
ARITHMETIC OPERATORS
Arithmetic operators are used for
mathematic calculations.
AAKASH KAUSHIK
9891983083,9289817971
RELATIONAL OPERATORS
A relationaloperatorcompares
twooperandsto determine whether one is
greater than, greater than or equal to, less
than, less than or equal to the other.
If the condition is true, it will return nonzero value, if the condition is false, it will
return 0.
AAKASH KAUSHIK
9891983083,9289817971
RELATIONAL OPERATORS
AAKASH KAUSHIK
9891983083,9289817971
LOGICAL
OPERATORS(AND,OR,NOT)
when
we have more then one
condition in a single
statement.
The logical operators&&and||are used
when evaluating two expressions to obtain
a single relational result.
The logical operator ! Is used for
negation purpose. Basically, it returns the
opposite Boolean value of evaluating its
operand.
AAKASH KAUSHIK
9891983083,9289817971
LOGICAL OPERATORS
AAKASH KAUSHIK
9891983083,9289817971
TERNARY OPERATORS
THE ONE AND ONLY TERNARY
OPERATOR IS CONDTIONAL
OPERATOR( ? : )
Output : Largest
number is : 5
AAKASH KAUSHIK
9891983083,9289817971
THANK
YOU
AAKASH KAUSHIK
9891983083,9289817971