# WHAT ARE OPERATORS?

The operators are the special type of functions that takes one or more parameters and gives new result. It is a symbol that tells the compiler to perform the mathematical and logical manipulations. The programming language like C or C++ is incomplete without the use of operators.

# SOME OF THE BUILT IN OPERATORS ARE

• Arithmetic operators
• Relational operators
• Logical operators
• Assignment operators
• Bitwise operators

So, let us have a look all these operators briefly.

# ARITHMETIC OPERATORS

The arithmetic operators are used to perform the arithmetic operations on the operands. The operations can be addition, multiplication, subtraction and division.

# LET US HAVE A LOOK AT THE EXAMPLE:

 1234567891011121314151617181920212223242526272829303132333435363738394041424344 #includeusing namespace std; int main() { int x = 5, y = 10, z; //printing x and y cout<<“x is:”<

Output:

x is:5andy is:10
```x+y is:15
x-y is:-5
x*y is:50
x/y is:0
x/ is:5
x++ is:6andz is:5
x-- is:5andz is:6```

# RELATIONAL OPERATORS

The relational operators are those operators that are used to compare the values of two operands. For example, by comparing two operands that their values are equal or not, or the value of one operand is greater than the other.

# LET US HAVE A LOOK AT THE EXAMPLE:

 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 #include  using namespace std; int main() {     int x=20, y=10;     // greater than     if (x > y)         cout<<“\nx is greater than y”;     else     cout<<“\nx is less than or equal to y”;     // greater than equal to     if (x >= y)         cout<<“\nx is greater than or equal to y”;     else cout<<“\nx is lesser than y”;     // less than     if (x < y)         cout<<“\nx is less than y”;     else cout<<“\nx is greater than or equal to y”;     // lesser than equal to     if (x <= y)         cout<<“\nx is lesser than or equal to y”;     else cout<<“\nx is greater than y”;     // equal to     if (x == y)         cout<<“\nx is equal to y”;     else cout<<“\nx and y are not equal”;     // not equal to     if (x != y)         cout<<“\nx is not equal to y”;     else cout<<“\nx is equal y”;     return (0); }

Output

```x is greater than y
x is greater than or equal to y
x is greater than or equal to y
x is greater than y
x and y are not equal
x is not equal to y```

# LOGICAL OPERATORS

The logical operators are those operators that are used to combine two or more conditions.  The logical operators are AND (&&) and OR (||). If we combine two statements using AND operator then only both the valid statements will be considered and if we combine two statements using OR operator then only either one of them will be considered.

# LET US HAVE A LOOK AT THE EXAMPLE:

 12345678910111213141516171819202122232425262728293031323334353637 #include  using namespace std;  int main() {     int x = 20, y = 5, z = 10, a = 15;     // logical AND     if (x>y && z==a)         cout<<“\nx is greater than y AND z is equal to a”;     else cout<<“AND condition is not satisfied”;     // logical OR     if (x>y || z==a)         cout<<“\nx is greater than y OR z is equal to a”;     else cout<<“\nNeither x is greater than y nor z is equal to a”;     // logical NOT     if (!x)         cout<<“\nx is zero”;     else cout<<“\nx is not zero”;     return (0); }
Output
```AND condition is not satisfied
x is greater than y OR z is equal to a
x is not zero```

# ASSIGNMENT OPERATORS

The assignment operators are those operators which are used to assign value to a variable. On the left side of the assignment operator the operand is a variable and the right side of the operator the operand is a value. The value on the right side of the operator should be of the same data type as of variable on the left side of the operator otherwise it will show a compile error.

# LET US HAVE A LOOK AT THE EXAMPLE:

 12345678910111213141516171819202122232425262728293031323334 #includeusing namespace std;int main() { int x = 15, y = 5; //printing x and y cout<<“\nx is = “<

Output:
```x is = 15 and y is = 5
x+y is=20
x-y is = 15
x*y is =75
x/y is = 15
x%y is = 0```

# BITWISE OPERATORS

The bitwise operators are those are used to perform bit level operations on the operands. In the bitwise operators first operators are converted to bit level and then calculation is performed on the operands. Some of the operations which are performed are addition, subtraction, multiplication, division, etc.

# LET US HAVE A LOOK AT THE EXAMPLE:

 123456789101112131415161718192021222324252627282930313233343536373839 #include  using namespace std;       int main() {    unsigned int x = 60;             // 60 = 0011 1100     unsigned int y = 13;             // 13 = 0000 1101    int z = 0;              z = x & y;             // 12 = 0000 1100    cout << “The value of z is : “ << z << endl ;    z = x | y;             // 61 = 0011 1101    cout << ” The value of z is: “ << z << endl ;    z = x ^ y;             // 49 = 0011 0001    cout << ” The value of z is: “ << z << endl ;    z = ~x;                // -61 = 1100 0011    cout << ” The value of z is: “ << z << endl ;    z = x << 2;            // 240 = 1111 0000    cout << ” The value of z is: “ << z << endl ;    z = x >> 2;            // 15 = 0000 1111    cout << ” The value of z is: “ << z << endl ;    return 0; }
Output :
```The value of z is : 12
The value of z is: 61
The value of z is: 49
The value of z is: -61
The value of z is: 240
The value of z is: 15```

# WHAT ARE EXPRESSIONS?

An expression is a sequence of operators and the operands. It is a form when you combine operands and operators.

# THE EXPRESSIONS ARE OF THREE TYPES

• Arithmetic expression
• Relational expression
• Logical expression

# ARITHMETIC EXPRESSION

An arithmetic expression is that expression in which arithmetic operators are used. Like addition, multiplication, subtraction, division, etc.

# RELATIONAL EXPRESSION

A relational expression is that expression in which relational operators are used. The operators provided in relational expression are less than (<), greater than (>), less than equal to (<=), greater than equal to (>=), etc.

# LOGICAL EXPRESSION

A logical expression is that expression in which logical operators are used. Some of the logical operators are AND (&&), OR (||), NOT (!).