Operator एक symbol होते हैं , जो process / operation represent करते हैं करते हैं , या हम कह सकते हैं की Operators को कोई process / या operation को perform करने के लिए use करते हैं।
For Example -

int a = 7;
int b = 89;
// = is a assignment operator
  
cout << a+b;
// here + is arithmetic operator

ऊपर दिए गए example में आप देखा सकते हैं कि + (plus sign) Operator define की गयी दो values को add रहा है।

Variable Operator

C++ Operators Types

इसी तरह से C++ हमें different - different Operators provide कराती है different - different action perform करने के लिए। C++ में normally use होने वाले Operators कुछ इस प्रकार हैं -

  1. Arithmetic Operators
  2. Assignment Operators
  3. Comparison / Relational Operators
  4. Logical Operators
  5. Increment / Decrement Operator

C++ Arithmetic Operators

Arithmetic Operators simple calculation में use होने wale Operators होते हैं जैसे Addition , Subtraction etc.

OperatorNameExampleExplanation
+Additionx+y
( + ) plus operator uses to add two or more numbers / values
-Subtraction

x-y

 ( -  ) minus  operator uses to substract one  numbers / values from another numbers / values or finds the difference 
/Divisionx / yquotient of x and y with decimal point.
*multiplicationx * yproduct of x and y
%Modulusx % yremainder of operands

C++ Assignment Operators

Assignment Operator को equals to = से represent करते हैं , जो कि value को किसी variable में assign करने के लिए use किया जाता है। हालाँकि इसे Arithmetic Operators के साथ भी use करते हैं। नीचे दिए गए Example में आप देख सकते हैं।

OperatorNameExampleExplanation
=Assignx = yvalue of y assigned to x
!=Assignx = yvalue of y assigned to x
+=Addition then Assign

x += y

First add and assign it to x. (It is same as x = x+y )
- =Subtract then Assign

x -= y

get the difference and assign it to x. (It is same as x = x-y )
/ =Divide then assign quotientx /= yquotient of x and y then assign it to x . (It is same as x = x/y )
* =Multiplication then assign the productx * =yproduct of x and y then assign it to x. (It is same as x = x*y )
% =Divide then assign remainder
x %= yremainder of operands then assign it to x. (It is same as x = x+%y )

C++ Comparison Operators

Comparison Operators दी हुई दो values को compare करके  (1 for true and 0 for false) value return करते हैं according to condition . C++ में Comparison Operators को कुछ इस तरह से use कर सकते हैं।

OperatorNameExampleExplanation
==Equalx = = ychecks if x is equal to y.
!=Not equalx !=ychecks if x is not equal to y.
<Less thanx < ychecks if x is less than y.
>Greater thanx > ychecks if x is greater than y.
<=Less than or equalx <= ychecks either x is less than or equal to y.
>=Greater than or equalx >= ychecks either x is greater than or equal to y.

C++ Incrementing/Decrementing Operators

Incrementing/Decrementing Operators को किसी variable को 1 से increase या decrease करने के लिए use किया जाता है। हालाँकि इसमें Addition और Subtraction operation ही होते हैं , इसलिए इसमें ( ++ ) या ( -- )  sign ही use होते हैं। नीचे table में आप देख सकते हैं किसा तरह से इन्हे use करते हैं और क्या Output generate हैं।

OperatorNameExplanation
++aPre Incrementfirst increment by 1 then return the value of a
a++post Incrementfirst return the value of a then increment by 1.
--aPre Decrementfirst decrement by 1 then return the value of a
a--Post Decrementfirst return the value of a then decrement by 1.

C++ Logical Operators

Logical Operators , एक या एक से अधिक expression के according Boolean value return करते हैं। जैसे -

OperatorNameExampleExplanation
andAndx and yReturns True if Both operands (x and y) are true;
orOr

x or y

Returns True if either or y is true;
xorXorx xor yReturns True if either x or y is true but not both.
&&Andx && ysame as and,returns True if Both operands (x and y) are true;
!Not!xReturns True if x is not true;
||Orx || ysame as or , returns True if either x or y is true;

Related Topics :

Rahul Kumar

Rahul Kumar

Hi ! I'm Rahul Kumar Rajput founder of learnhindituts.com. I'm a software developer having more than 4 years of experience. I love to talk about programming as well as writing technical tutorials and blogs that can help to others. I'm here to help you navigate the coding cosmos and turn your ideas into reality, keep coding, keep learning :)

Get connected with me. :) LinkedIn Twitter Instagram Facebook

b2eprogrammers