What are the different types of operators ? Explain with example
Answers
Answered by
5
Answer:
Different types of operators are:
- Assignment operators
- Mathematical operators
- Relational operators
- Logical operators
- Bitwise operators
- Shift operators
- Unary operators
- Ternary Operators
Answered by
0
There are total of 6 types of operators.Such as -
- Artihmetic Operators - It comprises addition, subtraction, multiplication, division, modulus operations, increment, and decrement, as well as other fundamental arithmetic operations. The following are the Arithmetic Operators in C and C++: + (Addition) – This operator adds two operands together,-(Subtraction) – Remove two operands from the equation , * (Multiplication) – Add two operands together, / (Division) – Divides two operands and returns the result as the quotient , percent (Modulus operation) – Finds the remaining of two integers after division and returns the remainder, — (Decrement) – This operator is used to decrease an operand's value.
- Relation operator: It is used to compare two numbers to see if they are equal, less than, less than or equal to, greater than, greater than or equal to, or more than, greater than or equal to. Example- ==, >, <, !=, >=, <=.
- Assignment Operators: This type of operator is used to assign a specific value to a variable. We'll go through it in depth with abbreviated notations in the next section. = as an example (Assignment), += (Addition Assignment), -= (Subtraction Assignment), *= (Multiplication Assignment), /= (Division Assignment) , %= (Remainder Assignment) .
- Logical operators: Boolean values such as AND, OR, and NOT are referred to as logical operators. The symbol && stands for Logical AND, which signifies True only if all operands are true. || denotes logical OR, which means True only if one of the operands is true. ! symbolizes logical Only if the operand is 0 is NOT True.
- Bitwise Operators: They are based on the boolean algebra principle of performing operations bit by bit. It improves the program's processing speed and, as a result, its efficiency.Example - Ex- & (Bitwise AND), | (Bitwise OR) –, ^ (Bitwise exclusive OR). ~ (One’s complement operator):. << – Left shift, >> – Right shift.
- Miscellaneous Operators: In addition to the above-mentioned operators, this category also includes comma, sizeo,f and ternary (conditional) operators.Ex- sizeof , & (Pointer), * (Pointer), ? (Condition) . The comma operator is used to connect similar expressions. The sizeof operator is a unary operator that yields data size (constants, variables, array, structure, etc).
Similar questions