Arithmetic Operators in C
For Complete YouTube Video: Click Here
In this class, we will try to understand Arithmetic Operators in C.
Before understanding Arithmetic Operators, we will try to understand operators.
To understand operators, we will consider the program in the Introduction to C Programming class.
int main() { int a, b, c; a = 10, b = 20; c = a + b; printf("%d", c); return 0; }
The third line of the program is c = a + b.
c = a + b is a mathematical expression.
In the above expression, a and b are operands = and + is an operator.
C Programming language has a stronghold on the operators.
It supports a variety of operators.
Types of Operators
The different types of operators are
- Arithmetic Operators
- Assignment Operators
- Increment and Decrement Operators
- Shift Operators
- Bitwise Operators
- Conditional Operators
- Relational Operators
- Logical Operators
Apart from these, we have many other operators. We will discuss those operators whenever the context comes.
Arithmetic Operators
The image below is the classification of arithmetic operators.
The arithmetic operators are classified into two types.
- Unary Operators
- Binary Operators
Binary operators are classified as Additive Arithmetic Operators and Multiplicative Arithmetic Operators.
Unary Arithmetic operators are used to emphasizing that a numeric constant is positive or negative. The unary operators will have only one operand.
Binary Arithmetic operators will have two operands.
Additive Arithmetic operators are + and – symbol.
Multiplicative Arithmetic operators are *, /, and %.
% indicates modulo division.
Modulo division produces the remainder after dividing two numbers.