Operators are the symbols which are used in C++ programming to do the math work or to do calculations in it.
All the symbols that are used in math can be used in C++ language with different functionality as well as the same functionality.
The operators in C++ are:
1- Arithmetic operators
2- Relational operators
3- Logical operators
4- Assignment Operators
Arithmetic operators are used to perform arithmetic calculations in C++. The operators are as follows
Operation | Symbol | Expression in C++ |
---|---|---|
Addition | + | a+b |
Subtraction | - | a-b |
Multiplication | * | a*b |
Divide | / | a/b |
Relational operators are used to compare two values. It evaluates the values and then give the result in true or false that either the statement is true or false. The relational operators are given below in the table.
Suppose a, b, and c three different values having the values of 242, 555 and 242 respectively then:
Operation | Symbol | Expression | Evaluation |
---|---|---|---|
Equal to (comparison) | == | a==c | True |
Less than | < | b<a | False |
Greater than | > | a>c | False |
Less than or equal to | <= | a<=b | True |
Greater than or equal to | >= | b>=a | True |
Not equal to | != | b!=a | True |