Search This Blog

Monday, September 8, 2014

Operators in C++ Language

An operator is a symbol that tells the compiler to perform specific mathematical or logical manipulations. C++ is rich in built-in operators and provides the following types of operators:

  • Assignment Operators
  • Arithmetic Operators
  • Relational Operators
  • Logical Operators
  • Bitwise Operators
  • Misc Operators

Arithmetic Operators:

There are following arithmetic operators supported by C++ language:
Assume variable A holds 10 and variable B holds 20, then:
OperatorDescriptionExample
+Adds two operandsA + B will give 30
-Subtracts second operand from the firstA - B will give -10
*Multiplies both operandsA * B will give 200
/Divides numerator by de-numeratorB / A will give 2
%Modulus Operator and remainder of after an integer divisionB % A will give 0
++Increment operator, increases integer value by oneA++ will give 11
--Decrement operator, decreases integer value by oneA-- will give 9

Relational Operators:

There are following relational operators supported by C++ language
Assume variable A holds 10 and variable B holds 20, then:
OperatorDescriptionExample
==Checks if the values of two operands are equal or not, if yes then condition becomes true.(A == B) is not true.
!=Checks if the values of two operands are equal or not, if values are not equal then condition becomes true.(A != B) is true.
>Checks if the value of left operand is greater than the value of right operand, if yes then condition becomes true.(A > B) is not true.
<Checks if the value of left operand is less than the value of right operand, if yes then condition becomes true.(A < B) is true.
>=Checks if the value of left operand is greater than or equal to the value of right operand, if yes then condition becomes true.(A >= B) is not true.
<=Checks if the value of left operand is less than or equal to the value of right operand, if yes then condition becomes true.(A <= B) is true.

25 comments:

  1. nice blog :) , thanks for the informations about programming :)

    ReplyDelete
  2. HI . THANKS 4 THE INFO . IT HELP MY SISTER A LOT NEXT SEM . =))

    ReplyDelete
  3. Thanks a lot. this is very helpful for us, student!

    ReplyDelete
  4. oh. this is what i've looking for. thanks for posting this!!

    ReplyDelete
  5. Nice blog !
    laking tulong neto sa mga nag tatake ng programming .. :)

    ReplyDelete
  6. Nice blog. Very much helpful. :) Keep it up.

    ReplyDelete
  7. It is easy to understand. This blog, helps me to learn more about programming. Specifically in operators. Good job.

    ReplyDelete
  8. Nice blog startup, wating for more new posts!! (Y)

    ReplyDelete
  9. Aba Ang Tindi naman ng Post ni Mam. :D
    Programming pa More. ^_^ God bless.

    ReplyDelete
  10. wow.. kaya mas trip ko ang c++ ee.. feeling ko mas pinadali ug codes kesa sa c.. pero sa tingin depende pa din sa gagamit kung saan sila madadalian.. :)

    btw.. nice info.. sana mas marami pang info na katulad nito ang malagay sa blog na to..

    ReplyDelete
  11. C++, mas mdali syang gamitin.. pra lang po SAKEN :))

    ReplyDelete
  12. Kudos programming!

    ReplyDelete
  13. This kind of Blog really helps students, especially those IT or computer programming courses, to know basic operators of C++ Language :) i hope for more useful and knowledgeable blogs form you :))

    ReplyDelete
  14. malaking tulong to sa mga estudyante :D

    ReplyDelete