C++ Operators

1. Arithmetic Operators

These operators are used to perform basic arithmetic operations.

  • + : Addition
  • - : Subtraction
  • * : Multiplication
  • / : Division
  • % : Modulus (remainder after division)

2. Relational Operators

These operators are used to compare two values.

  • == : Equal to
  • != : Not equal to
  • > : Greater than
  • < : Less than
  • >= : Greater than or equal to
  • <= : Less than or equal to

3. Logical Operators

These operators are used to perform logical operations.

  • && : Logical AND
  • || : Logical OR
  • ! : Logical NOT

4. Bitwise Operators

These operators are used to perform operations on individual bits.

  • & : Bitwise AND
  • | : Bitwise OR
  • ^ : Bitwise XOR
  • ~ : Bitwise NOT
  • << : Left shift
  • >> : Right shift

5. Assignment Operators

These operators are used to assign values to variables.

  • = : Simple assignment
  • += : Add and assign
  • -= : Subtract and assign
  • *= : Multiply and assign
  • /= : Divide and assign
  • %= : Modulus and assign
  • &= : Bitwise AND and assign
  • |= : Bitwise OR and assign
  • ^= : Bitwise XOR and assign
  • <<= : Left shift and assign
  • >>= : Right shift and assign

6. Increment and Decrement Operators

These operators are used to increase or decrease the value of a variable by 1.

  • ++ : Increment
  • -- : Decrement

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *