C++ Operators

Operators: Operators are the symbols which are used to perform some operations.

Operands: Operands is the variables on which operators perform operations.

Example:


7 + 8


7,8 operands and ‘+’ is operators

Types of Operators:

There are various types of operators:
  1. Input/Output Operators and Unary Operators
  2. Arithmetic Operators
  3. Relational Operators
  4. Logical Operators

Input Output Operators and Unary Operators:


<< Insertion Operator
Used to display output on console screen
>> Extraction Operator
Used to read value of variable from keyboard
+ Unary Plus
Used to specify that number is positive.
- Unary Minus
Used to specify that number is negative.
& Address Operator
Used to store the address of a variable in a pointer variable.
++ Increment Operator
Add one to the existing value of the variable
-- Decrement Operator
Used to subtract one from the existing value of variable

Arithmetic Operators


+ Addition
To add two numeric value
- Subtraction
Subtract two numeric value
* Multiplication
Multiply two numeric value
/ Divide
Divide one numeric value by another
% Modulus
Find Remainder after dividing one numeric value by another

Relational Operators


< Less Than
Check one value is smaller than another
<= Less Than Equal To
Check one value is smaller than or equal to another
> Greater Than
Check one value is greater than another
> Greater Than
Check one value is greater than another
>= Greater Than Equal To
Check one value is greater than or equal to another
== Equal To
Check one value is equal to another
!= Not Equal To
Check one value is not equal to another

Logical Operator


&& Logical AND
It combines two relational expressions. If any of the input is 0, output would be 0. If all the inputs are 1, output would be 1.
|| Logical OR
It combines two relational expressions. If any of the input is 1, output would be 1. If all the inputs are 1, output would be 0.
! Logical NOT
It is used to reverse the output of a relational or logical expression. If input is 1, output would be 0 and vice versa.

Back To Top