Operators in C++
Operators in C++
1. Operators in C++ :)
• An operator is a symbol that operates on a value to
perform specific mathematical or logical computations.
1. Unary Operators
2. Binary Operators
3. Ternary Operators
1.1 . Unary Operators :)
• These operators operate or work with a single operand.
For example: Increment(++) and Decrement(–)
Operators.
Name Symbol Description Example
Increases the integer int a = 15;
Increment Operator ++ value of the variable by
one a++; // returns 16
1. Arithmetic Operator
2. Relational Operator
3. Logical Operator
4. Bitwise Operator
5. Assignment Operator
1.2.1 Arithmetic Operator :)
Name Symbol Description Example
int a = 3, b = 6;
Addition + Adds two operands
int c = a+b; // c = 9
int a = 3, b = 6;
Multiplication * Multiplies two operands
int c = a*b; // c = 18
int a = 3, b = 6;
Is Equal To == Checks if both operands are equal a==b;
// returns false
int a = 3, b = 6;
Checks if first operand is greater than the
Greater Than > second operand a>b;
// returns false
int a = 3, b = 6;
Checks if first operand is greater than or
Greater Than or Equal To >= equal to the second operand a>=b;
// returns false
int a = 3, b = 6;
Checks if first operand is lesser than the
Less Than < a<b;
second operand
// returns true
int a = 3, b = 6;
Checks if first operand is lesser than or
Less Than or Equal To <= equal to the second operand a<=b;
// returns true
int a = 3, b = 6;
Not Equal To != Checks if both operands are not equal a!=b;
// returns true
1.2.3 Logical Operators :)
Name Symbol Description Example
int a = 3;
Returns true if the
Logical NOT ! !a;
operand is false or zero
// returns false
1.2.4 Bitwise Operators :)
Name Symbol Description Example