What is the usage of C++ operators?

C++ operators are special symbols used for performing various operations such as arithmetic, logical operations, and assignments. Here are some commonly used operators in C++ and their usage:

  1. Arithmetic operators:
  2. “+” is the symbol used for addition, it is used to perform the operation of adding two operands.
  3. “-” is the subtraction operator used to subtract two operands.
  4. “*” represents multiplication and is used to perform the multiplication of two operands.
  5. “/” is the division symbol used to divide two operands.
  6. “%”: Modulus operator, used to calculate the remainder after dividing two operands.
  7. Relational operators:
  8. “==” means equal to, it checks if two operands are equal.
  9. “!=”: means not equal to, it checks if the two operands are not equal.
  10. “>”: Greater than, check if the left operand is greater than the right operand.
  11. “<": Less than, checks if the left operand is smaller than the right operand.
  12. “>=”: greater than or equal to, checks if the left operand is greater than or equal to the right operand.
  13. “<=": less than or equal to, checks if the left operand is less than or equal to the right operand.
  14. Logical operators:
  15. “&&” is a logical AND operator used to check if both conditions are true at the same time.
  16. “||” is a logical OR operator used to check if at least one of the two conditions is true.
  17. “!” is a logical NOT operator used to negate a condition.
  18. Assignment operator:
  19. “=”: assignment operator used to assign the value of the right operand to the left operand.
  20. “+=”: add and assign, add the left operand to the right operand and assign the result to the left operand.
  21. “-=”: subtracts and assigns; subtracts the right operand from the left operand and assigns the result to the left operand.
  22. “*=” means multiply equals, it multiplies the left operand by the right operand and assigns the result to the left operand.
  23. “/=”: Divide the left operand by the right operand and assign the result to the left operand.

The above are just a portion of the C++ operators, there are many other operators such as increment, decrement operators, bitwise operators, conditional operators, etc., all with specific uses and functions.

bannerAds