C Lecture 4 Part 2
C Lecture 4 Part 2
Operators
1
Operator
2
3
Arithmetic Operators
4
Arithmetic operator
i. Binary Operator
5
Binary Operator
• Operators that operate or work with two operands are binary operators.
6
Addition ( + )
Example program:
7
Subtraction ( - ) :
Example program:
8
Multiplication ( * ):
Example program:
9
Division ( / ):
Example program:
10
Modulo ( % ):
• Returns the remainder of the division of the left operand by the right
operand.
Example program:
11
Unary Operator:
12
Unary minus( - ):
13
Increment( ++ ):
• The increment operator (++) is a unary operator that is used to increase
the value of its operand by 1.
• The increment operator can be applied to variables of numeric data
types such as integers and floating-point numbers.
Example program
Post-Increment:
A post-increment operator is used to increment the value of the variable after
executing the expression completely in which post-increment is used.
15
Decrement( -- ):
• The decrement operator (--) is a unary operator in C that is used to
decrease the value of its operand by 1.
• The decrement operator can be applied to variables of numeric data
types such as integers and floating-point numbers.
Example program:
Post-Decrement:
The post-decrement happens when the decrement operator is used as
the suffix of the variable.
17