Arithmetic operators in C language

Arithmetic operators are used in C language to perform basic mathematical operations on operands. The basic arithmetic operators in C are addition (+), subtraction (-), multiplication (*), division (/), and modulo (%) operators.

Here is the datatype table for arithmetic operators in C language:

Operator
Description
Example
Result Type
+
Addition
a + b
int or float
-
Subtraction
a - b
int or float
*
a * b
int or float
/
Division
a / b
int or float
%
Modulo
a % b
int

The addition(+) and subtraction(-) operators

The addition and subtraction operators are binary operators, meaning they require two operands to perform the operation.

Example:

int a = 5, b = 3;
int sum = a + b;    // sum will be 8
int diff = a - b;   // diff will be 2

The multiplication(*) and division(/) operators

The multiplication and division operators are also binary operators, and they perform the operation based on the precedence rules of arithmetic.

Example:

int a = 5, b = 3;
int product = a * b;    // product will be 15
int quotient = a / b;   // quotient will be 1

The modulo(%) operator

The modulo operator returns the remainder of a division operation between two operands.

Example:

int a = 5, b = 3;
int remainder = a % b;  // remainder will be 2

Understanding C’s arithmetic operators’ precedence rules are crucial. Priority is given to division, modulo, and these operations above addition and subtraction. To make the order of actions explicit, using parenthesis is always a smart idea.