Operations Expressions
Operations Expressions
CHAPTER - 5
Operators
•
An Operator is a symbol used for certain
type of manipulations, logical or
mathematical.
•
The data on which the operators act are
called operands.
Types of operators
•
Unary
•
Binary
•
Ternary
•
Special
Unary operator
•
Operator that operate on a single operand
are known as unary operators.
Unary plus(+)
Unary minus(-)
Increment (++)
Decrement (--)
Logical Not (!)
Address of (&)
Binary operators
•
Arithmetic operators
•
Relational Operators
•
Logical Operators
•
Assignment operators
•
Bitwise operators
Arithmetic operators
•
C supports five arithmetic operators.
These operators are used for arithmetic
calculations
(E-x) A = 10 , B=20
Opera Description Example
tor
+ Adds two operands. A + B = 30
− Subtracts second operand A − B = -10
from the first.
* Multiplies both operands. A * B = 200
/ Divides numerator by de- B/A=2
numerator.
% Modulus Operator and B%A=0
remainder of after an integer
division.
Relational operators
Operator Description Example
, Comma operator
sizeof Size in bytes
& Address of operand
* Accessing the value at
that address
. Dot operator
arrow operator
Comma operator
•
The comma operator is used as
separators.
•
E-x
•
variable = exp1,exp2,…expn
sizeof operator
•
The sizeof operator returns the size in
bytes of the operand on the right.
The syntax is
sizeof(n)
Where n can be a variable, a constant or a
datatype.
Expressions