# Operators in C++

448

10

2

## Introduction: Operators in C++

An operator is a symbol that tells the compiler to perform specific mathematical or logical manipulations. C++ is rich in built-in operators and provides the following types of operators:

1) Arithmetic Operators

2) Relational Operators

3) Logical Operators

4) Bitwise Operators

5) Assignment Operators

6) Misc Operators

This chapter will examine the arithmetic, relational, logical and assignment operators one by one. Others are not needed for beginners......

### Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

## Step 1: Arithmetic Operators

### There are following arithmetic operators supported by C++ language:

2) Subtraction (-)

3) Multiplication (*)

4) Division (/)

5) Modulus (%)

6) Increment (++)

7) Decrement (--)

They are explained well in the image above.

## Step 2: Relational Operators

There are following are Relational Operators in C++ :-

SUPPOSE A HOLDS VALUE 10 AND B HOLDS 20

1) == - Checks whether value of two operands are equal or not, if yes then it becomes true.

A == B is not true

2) != - Checks whether value of two operands are unequal or not, if yes then it becomes true.

A != B is true

3) < - Checks whether one operand is greater than other or not, if yes then it becomes true.

A < B is true

4) > - Checks whether one operand is greater than other or not, if yes then it becomes true.

A > B is not true

5) >= - Checks whether left operand is greater than or equal to the other or not, if yes then it becomes true.

A >= B is not true

6) <= - Checks whether right operand is greater than or equal to the other or not, if yes then it becomes true.

A <= B is true

## Step 3: Logical Operators

There are following logical operators supported by C++ language

Assume variable A holds 1 and variable B holds 0, then:

1) && - Called logical AND operator. If both the operands satisfy all the given conditions then it becomes true.

A == 1 && B == 0 is true BUT A == 0 && B == 0 is not true

2) || - Called logical OR operator. If both the operands satisfy either of the given conditions then it becomes true.

A == 0 || B == 0 is true.

3) ! - Called logical NOT operator. Use to reverse the logical state of an operand. If a condition is true then it becomes false.

!(A == 1 && B == 1) is true BUT !(A == 1 && B == 0) is not true.

## Step 4: Assignment Operators

There are following assignment operators supported by C++ language:

1) =

2) +=

3) -=

4) *=

5) /=

6) %=

THEY ARE EXPLAINED IN THE IMAGE ABOVE

## Step 5: ABOUT MY NEXT INSTRUCTABLE

I will be posting my next instructable on CONDITIONAL STATEMENTS probably by tomorrow.....

Please like and share my instructable and support me friends...... THANK YOU

## Recommendations

236
36 4.9K
88 6.5K
MIG Welding Class

253 Enrolled

## 2 Discussions

ok i will keep it in mind the next time

Simple and clean, good for beginers :).

You should explain the differences between pre and post-increment operators "++a" or "a++" as elements in an expresion.

I think the rest of operators should be mentioned even when the instructable is intended for beginers. Operators like << >> , [ ] -> . (cast), etc.