Tuesday, 28 July 2026

Operators in C Programming ,Arithmetic ,Relational , Logical & Assignment Operator Explained .

➕ Operators in C Programming

Arithmetic, Relational, Logical & Assignment Operators Explained

Learn How Computers Perform Calculations and Decisions 🚀


🚀 Introduction

In the previous lesson, we learned about Variables and Data Types.

Now we will learn how to perform operations on stored data using Operators.

"Operators are special symbols used to perform operations on data."


💻 Simple Example


int a = 10;
int b = 5;

int sum = a + b;

Here + is an operator that adds two numbers.


🔥 Types of Operators in C

➕ Arithmetic Operators

Used for mathematical calculations.

⚖️ Relational Operators

Used to compare values.

🧠 Logical Operators

Used for combining conditions.

📝 Assignment Operators

Used to assign values.


➕ Arithmetic Operators

Operator Meaning Example
+ Addition 10 + 5 = 15
- Subtraction 10 - 5 = 5
* Multiplication 10 * 5 = 50
/ Division 10 / 5 = 2
% Remainder 10 % 3 = 1

⚖️ Relational Operators

These operators compare two values and return True or False.


>   Greater than

<   Less than

==  Equal to

!=  Not equal

>=  Greater or equal

<=  Less or equal


🧠 Logical Operators

Operator Meaning
&& AND - Both conditions true
|| OR - Any one condition true
! NOT - Reverse result

📝 Assignment Operators

Assignment operators store values in variables.


int x = 10;

x += 5;   // x = x + 5

x -= 2;   // x = x - 2


💻 C Program Using Operators



#include <stdio.h>

int main()
{

int a = 20;
int b = 10;

printf("Addition = %d", a+b);

printf("\nSubtraction = %d", a-b);

printf("\nMultiplication = %d", a*b);

printf("\nDivision = %d", a/b);

return 0;

}



🖥️ Output

Addition = 30
Subtraction = 10
Multiplication = 200
Division = 2

⭐ Why Are Operators Important?

  • Perform calculations
  • Compare data
  • Create decision-making programs
  • Build complex applications
  • Control program logic

🎯 Conclusion

Operators are the tools that allow programs to calculate, compare and make decisions.

Next: Input and Output in C Programming ⌨️🚀

No comments:

Post a Comment