2. v The operators is a symbol that tells the
computer to perform certain mathematical
or logical manipulations.
v Operators are used in programs to
manipulate data and variables.
v They usually form a part of the
mathematical or logical expressions.
Copyright 息 2017 by Milap Bhanderi
4. Arithmetic operator
Operator Meaning
+ Addition or unary plus
- Subtraction or unary minus
* Multiplication
/ Division
% Modulo division
Copyright 息 2017 by Milap Bhanderi
5. Relational Operators
Operator Meaning
< Is less than
<= Is less than or equal to
> Is greater than
>= Is greater than or equal to
== Equal to
!= Not equal to
Copyright 息 2017 by Milap Bhanderi
6. Logical Operators
Operator Meaning
&& Logical AND
|| Logical OR
! Logical NOT
Logical expression or a compound relational expression :
An expression that combines two or more relational expressions
Ex: if (a==b && b==c)
Copyright 息 2017 by Milap Bhanderi
10. Increment & Decrement Operators
C supports 2 useful operators namely :
1. Increment ++
2. Decrement --
The ++ operator adds a value 1 to the operand
The operator subtracts 1 from the operand
++a or a++
--a or a--
Copyright 息 2017 by Milap Bhanderi
11. Rules for ++ & -- operators
1. These require variables as their operands
2. When postfix either ++ or is used with the
variable in a given expression, the expression
is evaluated first and then it is incremented or
decremented by one
3. When prefix either ++ or is used with the
variable in a given expression, it is
incremented or decremented by one first and
then the expression is evaluated with the new
value Copyright 息 2017 by Milap Bhanderi
12. Conditional operators
Syntax:
Where , and are expressions
Working of the ? Operator :
Exp1 is evaluated first, if it is nonzero(1/true)
then the expression2 is evaluated and this
becomes the value of the expression,
If exp1 is false(0/zero) exp3 is evaluated and its
value becomes the value of the expression
Ex: m=2;
n=3
r=(m>n) ? m : n; Copyright 息 2017 by Milap Bhanderi