Following are the types of operators in c++:
1. Arithmetic operators2. Conditional operators
3. Logical operators
4. Miscallaneous operators
1. ARTITHMETIC OPERATORS:
These are +, -, *, /. These are pretty simple to use.2. CONDITIONAL OPERATORS:
These are &&, ||, !.The && operator is used for and operation.
The || opeartos is used for an or operation.
The ! operator reverses the output. If this operator is used in a bool function. Then, if the output is true and this operator is used on that value then, the output will become false.
3:LOGICAL OPERATORS:
These are similar to the conditional operators.4: MISCALLANEOUS OPERATORS:
These are ++, --, sizeof(), ternary i.e. conditoin ?value if true:value if false, comma(,), & and *.The ++ operatos is used in two ways.
a. It is used to preincrement a value that increments the value first and then prints the value.
b. It is used to postincrement a value that increments the value after printing the value.
Similarly, the -- operator is used in two ways:
a. It is used to predecrerment a value that decrements the value first and then prints the value.
b. It is used to postdecrerment a value that decrements the value after printing the value.
The condition?X:Y operator is used as:
First of all, there is a condition, if the condition is true then the X value or function will be executed and if the condition is false then the Y value of function will be executed.
comma(,) is used as:
if we write int a(2, 3, 4), then the value of a will be used as 4 due to comma operator.
& operator is used to reference(copy) the address of a variable in the memory.
* operator is used to make a pointer.

0 Comments