Skip to content

Operators

Artemis edited this page May 12, 2023 · 2 revisions

Operators in C++

Operators are symbols that are used to perform operations on variables and values in C++. Operators are used to manipulate data and variables, and they form the basis of all expressions in the language.

Types of Operators

  1. Arithmetic Operators: Arithmetic operators are used to perform mathematical operations on one or more operands. These include addition (+), subtraction (-), multiplication (*), division (/), modulus (%), and so on.

  2. Relational Operators: Relational operators compare two values and return true or false depending on the result of the comparison. These include equality (==), inequality (!=), greater than (>), less than (<), greater than or equal to (>=), and less than or equal to (<=).

  3. Logical Operators: Logical operators are used to create logical expressions and return true or false depending on the result of the expression. These include the AND (&&) and OR (||) operators.

  4. Assignment Operators: Assignment operators are used to assign a value to a variable. These include the equal sign (=), plus equal (+=), minus equal (-=), and so on.

  5. Bitwise Operators: Bitwise operators are used to perform bitwise operations on two operands. These include bitwise AND (&), bitwise OR (|), bitwise XOR (^), and so on.

  6. Increment/Decrement Operators: Increment/decrement operators are used to increase or decrease a value by one. These include the increment (++) and decrement (--) operators.

  7. Special Operators: Special operators are used to perform special operations on variables. These include the size of operator (sizeof) and the address of operator (&).

Clone this wiki locally