DEV Community

Cover image for What is an Operator?
Mukesh Kumar
Mukesh Kumar

Posted on

What is an Operator?

🎙️ Introduction

Hello everyone!

Until now, we have learned about:

Data

Data Types

Variables

Constants

We learned how to store information inside a program.

But now think about this:

👉 Is storing data enough?
👉 How do we calculate marks?
👉 How do we compare values?
👉 How do we make decisions in a program?

The answer to all these questions is — Operators...Read More

🔹 Step 1: Basic Definition of an Operator

An operator is a special symbol that performs an operation on one or more operands.

In simple words:

👉 An operator tells the computer to perform a specific task.

For example:

tells the computer to add

tells the computer to subtract

tells the computer to multiply

/ tells the computer to divide

These symbols are called operators.

The values on which operators act are called operands...Read More

🔹 Step 2: Why Do We Need Operators?

Programming is not just about storing values.

It is about:

Performing calculations

Comparing values

Making decisions

Updating data

Without operators:

We cannot add two numbers.

We cannot compare two values...Read More

🔹 Step 3: Operators Work on Operands

An operator always works on data.

There are three types of operations based on operands:

1️⃣ Unary Operator
Works on one operand
Example: ++a

2️⃣ Binary Operator
Works on two operands
Example: a + b

3️⃣ Ternary Operator
Works on three operands...Read More

🔹 Step 4: Simple Real-Life Example

Imagine you have two numbers:

10 and 5

If you want to:

Add them → Use +

Subtract them → Use -

Multiply them → Use *

Compare them → Use > or <

These symbols perform actions...Read More

🔹 Step 5: Importance of Operators

Operators are important because they:

Perform arithmetic calculations

Help in decision-making

Control program flow

Modify variable values

Build logical expressions...Read More

🔹 Step 6: Operators in C Language

C language provides different types of operators such as:

Arithmetic Operators

Relational Operators

Logical Operators

Assignment Operators

Increment and Decrement Operators...Read More

📌 Summary

In this chapter, we learned:

An operator is a symbol that performs an operation.

It works on operands.

It is used for calculation, comparison, and logic...Read More

Top comments (0)