DEV Community

Cover image for Arithmetic Operators in C
Mukesh Kumar
Mukesh Kumar

Posted on

Arithmetic Operators in C

🎙️ Introduction

Hello everyone!

In the previous chapter, we learned about different types of operators in C.

Now, in this chapter, we will focus on one of the most important types — Arithmetic Operators.

Arithmetic operators are used to perform mathematical...Read More

🔹 Step 1: What Are Arithmetic Operators?

Arithmetic operators are symbols used to perform mathematical operations on variables and constants.

They work just like the mathematical symbols we use in school.

For example:

If we have two numbers, we may want to...Read More

🔹 Step 2: Types of Arithmetic Operators in C

C language provides five main arithmetic operators:

1️⃣ Addition (+)
2️⃣ Subtraction (-)
3️⃣ Multiplication (*)
4️⃣ Division (/)
5️⃣ Modulus (%)

Let us understand each one clearly...Read More

🔹 Step 3: Addition Operator (+)

The addition operator is used to add two values.

Example concept:
If a = 10 and b = 5

Then:
a + b gives 15

It is used to calculate:

Total marks

Sum of numbers

Total price

Addition is one of the most commonly...Read More

🔹 Step 4: Subtraction Operator (-)

The subtraction operator subtracts one value from another.

If a = 10 and b = 5

Then:
a - b gives 5

It is used in:

Calculating difference

Finding remaining balance...Read More

🔹 Step 5: Multiplication Operator (*)

The multiplication operator multiplies two values.

If a = 10 and b = 5

Then:
a * b gives 50

It is used in:

Area calculation

Salary calculation...Read More

🔹 Step 6: Division Operator (/)

The division operator divides one value by another.

If a = 10 and b = 5

Then:
a / b gives 2

Important point:

If both operands are integers, the result will...Read More

🔹 Step 7: Modulus Operator (%)

The modulus operator returns the remainder after division.

If a = 10 and b = 3

Then:
a % b gives 1

Because:
10 divided by 3 gives remainder 1.

Modulus is commonly used in:

Checking even or odd numbers...Read More

🔹 Step 8: Order of Execution (Operator Precedence)

When multiple arithmetic operators are used together, C follows a specific order of execution.

The order is:

Multiplication (*), Division (/), Modulus (%)

Addition (+), Subtraction (-)

This follows the mathematical rule called BODMAS...Read More

🔹 Step 9: Real-Life Example

Imagine a student scoring marks in 5 subjects.

To calculate total:
Use addition operator.

To calculate average:
Use addition and division.

To calculate percentage:
Use multiplication and division...Read More

📌 Summary

In this chapter, we learned:

Arithmetic operators are used for mathematical calculations.

The five main arithmetic operators are:

(Addition)

(Subtraction)

(Multiplication)...Read More

Top comments (0)