# Operators in C++8 min read

An operator is a symbol that performs a specific mathematical or logical operation on operands.
Example: Addition : `2 + 3`, where 2 and 3 are the operands and + is the operator.

We can say that operators are the foundation of any programming language, the program is incomplete without the operators as we use them in all of our programs.

Following are the types of Operators in C++.

• Arithmetic Operators
• Increment and Decrement Operators
• Assignment Operators
• Relational Operators
• Logical Operators
• Bitwise Operators
• Other Operators

### C++ Arithmetic Operators

These are used to perform mathematical operations on operands such as addition, subtraction, multiplication, division etc.

### C++ Increment and Decrement Operators

These are the Unary Operators as they operate on a single operand. They are `++` and `--` operators. ++ is used to increase the value by 1 and — is used to decrease the value by 1. There are two kinds of Increment and Decrement Operators.

• Post-Increment or Post-Decrement:
First, the value is used for operation and then incremented or decremented. Represented as a++ or a–.
• Pre-Increment Pre-Decrement:
Here First the value is incremented or decremented then used for the operation. Represented as ++a or –a.

### C++ Assignment Operators

Assignment operators are used in a program to assign a value of the right-hand side to the left-hand side as shown below.

These are the short version formed by combining the two operators. For example Instead of writing, `int a = a+5`, we can write `a += 5`.

Following are the list of assignment operators used in C++.

### C++ Relational Operators

These operators are used to compare two values and return Boolean results. For example: it checks if the operand is equal to another operand or not or an operand is greater than the other operand or not or checks less than between two values, etc.

List of relational operators in C++:

### C++ Logical Operators

Logical Operators are used in conditional statements and loops for evaluating a condition with binary values. They are used to combine two different expressions together.

The following are the C++ Logical Operators. Assume X holds the value 1 and Y holds 0

### C++ Bitwise Operators

Bitwise operators are used to perform a bit-level operation on operands. They are used in testing, setting, or shifting the actual bits in a program.

You can see the truth table below.

Below are the list of Bitwise operators:

### Other Operators

Apart from the above operators, there are various other operators used in C++ programming. They are listed below.

## Operators Precedence in C++

In a program, there may be an expression that uses more than one operator, in such case operator precedence determines which is to be evaluated first and next.

Let us take an example:

The output of the above expression is 60 because the precedence of multiplication is higher than the addition. So first (5 * 10) is evaluated and then 10 is added to the result.

The following shows the precedence and associativity of C++ operators:

Associativity refers to the direction of the operators to be evaluated first and next. It may be right to left or left to right.

### String Pattern Programs in C

In this tutorial, we will write various C pattern programs for String. Before that, you may go through the following topics in C. for loop …

### Java Program to Find pair of Integers in Array whose sum is given Number

In this tutorial, we will write a program to find a pair of elements from an array whose sum equals a given number in java …

### Program to Print Diamond Alphabet Patterns in C

In this tutorial, we will learn to write a C program to print Diamond patterns using alphabets/characters. However, in this tutorial, we will create a …

### Half Diamond Pattern in C using Alphabets

In this tutorial, we will learn and code the half diamond alphabet patterns in C programming language. However, in this tutorial, we will create a …

### Half Pyramid of Alphabets in C

In this tutorial, we will learn and code alphabet patterns in C programming language specifically the Half pyramid of alphabets in C programming. However, in …

### Inverted Half Pyramid Pattern of Alphabets in C

In this tutorial, we will write a C program to print half Pyramid using alphabets/characters. Before that, you may go through the following topic in …