Operators in C++

📘 C++ 👁 48 views 📅 Dec 22, 2025
⏱ Estimated reading time: 2 min

An operator is a symbol used to perform operations on variables and values.


1. Arithmetic Operators

Used for mathematical calculations.

OperatorDescriptionExample
+Additiona + b
-Subtractiona - b
*Multiplicationa * b
/Divisiona / b
%Modulus (remainder)a % b

2. Relational (Comparison) Operators

Used to compare values.

OperatorDescriptionExample
==Equal toa == b
!=Not equal toa != b
>Greater thana > b
<Less thana < b>
>=Greater than or equal toa >= b
<=Less than or equal toa <= b

3. Logical Operators

Used to combine conditions.

OperatorDescriptionExample
&&Logical ANDa > 0 && b > 0
`
`
!Logical NOT!a

4. Assignment Operators

Used to assign values.

OperatorDescriptionExample
=Assigna = 5
+=Add and assigna += 2
-=Subtract and assigna -= 2
*=Multiply and assigna *= 2
/=Divide and assigna /= 2

5. Increment and Decrement Operators

Used to increase or decrease a value by 1.

OperatorDescriptionExample
++Incrementa++
--Decrementa--

6. Bitwise Operators

Used for bit-level operations.

OperatorDescriptionExample
&ANDa & b
``OR
^XORa ^ b
~NOT~a
<<Left shifta << 1>
>>Right shifta >> 1

7. Conditional (Ternary) Operator

Used as a short form of if-else.

result = (a > b) ? a : b;

8. Special Operators

  • sizeof – returns size of a data type

  • , (comma) – evaluates multiple expressions

  • . – accesses class members

  • -> – accesses members using pointers


Key Points

  • Operators perform operations on data

  • Different operators serve different purposes

  • Correct operator usage is essential for logic building


Conclusion

Operators are fundamental building blocks in C++ programs that allow computation, comparison, and decision-making.


🔒 Some advanced sections are available for Registered Members
Register Now

Share this Post


← Back to Tutorials

Popular Competitive Exam Quizzes

🤖 AI Quizer Assistant

📝 Quiz
📚 Categories
🏆 Leaderboard
📊 My Score
❓ Help
👋 Hi! I'm your AI quiz assistant for Quizer.in!

I can help you with:
• 📝 Finding quizzes
• 🏆 Checking leaderboard
• 📊 Your performance stats

Type 'help' to get started! 🚀
AI is thinking...