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

  1. Arithmetic Operators
  2. Assignment Operators
  3. Increment and Decrement Operators
  4. Shift Operators
  5. Bitwise Operators
  6. Conditional Operators
  7. Relational Operators
  8. 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.

Types of Arithmetic Operators
Types of Arithmetic Operators

The arithmetic operators are classified into two types.

  1. Unary Operators
  2. 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.