Operators in C++

Level : Beginner
Mentor: Shailendra Chauhan
Duration : 00:02:00

What are the operators in the C++ language?

Operators are specialized symbols that perform mathematical and logical operations on variables & symbols known as operands.

Types of Operators in C++

Following are the Types of Operators in C++:

• Arithmetic Operators
• Relational Operators
• Logical Operators
• Bitwise Operators
• Assignment Operators
• Unary Operators
• Ternaryâ€‹ Operators
• Misc Operators

Arithmetic Operators

These operators carry out basic mathematical operations such as addition, subtraction, multiplication, and division.

Relational Operators

They're also known as comparison operators. They compare the values of the two operands. The comparison produces one of two results: true or false. If the comparison is successful, it returns 1; if the comparison fails, it returns 0. These are referred to as boolean values.

Logical Operators

They're used to combine two or more conditions or limitations. It results in 0 or 1 based on whether the expression is true or false. If the result is true, it returns 1. Otherwise, it returns 0. Logical operators are used to make decisions and create looping sentences.

Bitwise Operators

These operators work with individual bits. The operands are first transformed into bits, such as 0 or 1 before the calculation is done on them.

Assignment Operators

These are used to provide values for the variables. The most fundamental assignment operator is equal (=).

Conditional Operator

This is also known as a ternary operator. It works with three operands. The ternary operator is used to execute one group of statements when the test expression is true and another set of statements when it is false.

Precedence of Operators in C++

Still have some questions? Let's discuss.