DEV Community

Cover image for Types of Operators in C
Mukesh Kumar
Mukesh Kumar

Posted on

Types of Operators in C

🎙️ Introduction

Hello everyone!

In the previous lesson, we understood what an operator is.

We learned that:

👉 An operator is a symbol that performs operations on data.

Now the next question is:

👉 How many types of operators are there in C...Read More

🔹 Step 1: Classification of Operators in C

C language provides several types of operators. They are mainly classified into:

1️⃣ Arithmetic Operators
2️⃣ Relational Operators
3️⃣ Logical Operators
4️⃣ Assignment Operators
5️⃣ Increment and Decrement Operators
6️⃣ Bitwise Operators
7️⃣ Conditional (Ternary) Operator
8️⃣ Special Operators

Each category performs a specific type of task...Read More

🔹 Step 2: Arithmetic Operators

Arithmetic operators are used to perform mathematical calculations.

They include:

Addition (+)

Subtraction (-)

Multiplication (*)

Division (/)

Modulus (%)

These operators are used in calculations such as...Read More

🔹 Step 3: Relational Operators

Relational operators compare two values.

They return either true or false.

They include:

== (Equal to)

!= (Not equal to)

(Greater than)

< (Less than)

= (Greater than or equal to)...Read More

🔹 Step 4: Logical Operators

Logical operators are used to combine multiple conditions.

They include:

&& (Logical AND)

|| (Logical OR)

! (Logical NOT)

For example:
If a student passes math AND science, then...Read More

🔹 Step 5: Assignment Operators

Assignment operators are used to assign values to variables.

Basic assignment operator:

Example:
a = 10

Compound assignment operators:

+=

-=

*=

/=

%=

These operators shorten the code an...Read More

🔹 Step 6: Increment and Decrement Operators

These operators increase or decrease the value of a variable by 1.

++ (Increment)

-- (Decrement)

They are commonly used in:

Loops

Counters

Iteration processes

They make counting operat...Read More

🔹 Step 7: Bitwise Operators

Bitwise operators operate directly on binary values (bits).

They include:

& (Bitwise AND)

| (Bitwise OR)

^ (Bitwise XOR)

~ (Bitwise NOT)

<< (Left Shift)

(Right Shift)

These are mostly used in...Read More

🔹 Step 8: Conditional (Ternary) Operator

The conditional operator is written as:

? :

It is a short form of if-else.

Structure:
condition ? expression1 : expression2

It makes programs shorter and more...Read More

🔹 Step 9: Special Operators

C also provides some special operators such as:

sizeof (returns size of data type)

Comma operator

Pointer operators (* and &)

Member access operators (., ->)

These operators are used in advanced...Read More

📌 Summary

In this chapter, we learned that C language has different types of operators:

Arithmetic → For calculations

Relational → For comparisons

Logical → For combining conditions

Assignment → For assigning values

Increment/Decrement → For increasing or decreasing...Read More

Top comments (0)