Operators - C P P

Arithmetic Operator


  • Unary
    • ++N, --N, N++, N--
  • Binary
    • +, -, *, /, %

Relational Operator


  • Returns Boolean value
  • Types
    • ==, !=, >, <, >=, <=

Logical Operator


  • Used to connect multiple expressions or conditions together
  • Types
    • &&, ||, !

Bitwise Operator


  • Operate on bits and perform bit-by-bit operations
  • Types
    • & => AND
    • | => OR
    • ~
      • After inverting the 1st bit represents the sign => 1 means -ve, 0 means +ve
      • Take 2's complement of rest to find the number
    • ^ => XOR
    • n >> N
      • Right Shift, Generally value of 'n' gets divided by 2N
      • In case of +ve number Padding with 0, In case of -ve number it is Compiler dependent
    • n << N
      • Left Shift, Generally value of 'n' gets multiplied by 2N
      • In case of +ve number Padding with 0, In case of -ve number it is Compiler dependent

Assignment Operator


  • Types
    • =, +=, -=, *=, /=

Miscellaneous Operator


  • Types
    • & => Memory Address
    • * => Pointer
    • , => Used while printing in console
Share: