Arithmetic operators are fundamental in any programming language, and C is no exception. These operators perform various mathematical operations, from basic addition and subtraction to more complex operations like modulus and exponentiation. The operators include addition (+), subtraction (), multiplication (*), division (/), and modulo (%).
What are arithmetic operators in C?
Arithmetic operators are symbols used to perform mathematical calculations. The main arithmetic operators in C are addition +, subtraction , multiplication *, division /, and modulus %.
Example
C
C
#include <stdio.h> int main() { int a = 10, b = 5; printf("Addition: %d\n", a + b); printf("Subtraction: %d\n", a  b); printf("Multiplication: %d\n", a * b); printf("Division: %d\n", a / b); printf("Modulus: %d\n", a % b);
In the above code, each line performs an arithmetic operation on variables a and b using different arithmetic operators.
Get the tech career you deserve, faster!
Connect with our expert counsellors to understand how to hack your way to success
User rating 4.7/5
1:1 doubt support
95% placement record
Akash Pal
Senior Software Engineer
326% Hike After Job Bootcamp
Himanshu Gusain
Programmer Analyst
32 LPA After Job Bootcamp
After Job Bootcamp
Types of Arithmetic Operators in C
There are two main types of arithmetic operators in C
Binary arithmetic operators
Unary arithmetic operators
Binary Arithmetic Operators in C
Operator
Description
Example
+
Addition
a + b

Subtraction
a  b
*
Multiplication
a * b
/
Division
a / b
%
Modulus (Remainder)
a % b
Example of Binary Arithmetic Operator in C
In this example, we will use two binary operators â€“ â€śâ€ť and â€ś*â€ť in C and print the result using printf().
C
C
#include <stdio.h>
int main() { int res = 75  5*5; printf("%d", res);
return 0; }
Output:
Unary Arithmetic Operators in C
Operator
Description
Example
+
Unary Plus
+a

Unary Minus
a
++
Increment
a++

Decrement
a
Increment Operator in C
The unary increment operator("++") in C is used for incrementing the value of a variable by one.
1. PreIncrement
This is performed by using this operator before a variable, which increments the variable's value before it is used in an expression.
2. PostIncrement
This is performed by using this operator after a variable, which increments the variable's value after it is used in an expression.
Decrement Operator in C
The unary decrement operator("") in C is used for decrementing the value of a variable by one.
1. PreDecrement
This is performed by using this operator before a variable, which decrements the variable's value before it is used in an expression.
2. PostDecrement
This is performed by using this operator after a variable, which decrements the variable's value after it is used in an expression.
Example of Unary Arithmetic Operator in C
In this example, we will use two unary operators â€“ â€ś++â€ť and â€śâ€ť in C and print the result using printf().
C
C
#include <stdio.h>
int main() { int a = 48, b = 3; int res = (a++) + (b) ; printf("%d", res);
return 0; }
Output:
Frequently Asked Questions
Name the list of arithmetic operators in C language?
( + ) Addition Operator.
( â€“ ) Subtraction Operator.
( * ) Multiplication Operator.
( / ) Division Operator.
( % ) Modulo Operator.
( ++ ) Increment Operator.
( â€” ) Decrement Operator.
( + ) Unary Plus Operator.
What is the use of the modulus operator in C?
In C's arithmetic operators, the modulus operator calculates the remainder of integer division between two operands. It divides the numerator by the denominator to determine the result, effectively producing the remainder.
How does the division operator work with different operand types?
If both operands are integers, the result of the division operation will be an integer. If one or both operands are floating points, the result will be a floatingpoint number.
What are arithmetic logical and relational operators in C?
In C programming language, arithmetic operators perform mathematical operations (+, , *, /, %). Logical operators work with boolean values (&&, , !) for logical expressions. Relational operators compare values (==, !=, <, >, <=, >=).
What is the difference between increment/decrement operators and addition/subtraction?
The Increment Operator adds 1 to the operand, while the Decrement Operator subtracts 1 from the operand. The Postfix decrement operator involves evaluating the expression with the variable's initial value before decreasing the variable itself.
Conclusion
Arithmetic operators in C allow programmers to perform a variety of mathematical calculations, making them an indispensable part of the language. Understanding these operators and their specific behaviors is vital for writing efficient and effective C code.
We hope this blog helped you to understand the concept of the Arithmetic Operators in C. You can refer to our guided paths on the Coding Ninjas Studio platform. You can check our course to learn more about DSA, DBMS, Competitive Programming, Python, Java, JavaScript, etc.