Operators

 

Operators

An operator is a special symbol that is combined with one or more operands to perform specific operations and then return a result.




Types of Operators:
  • Arithmetic Operators
  • Assignment Operators.
  • Comparison Operators.
  • Logical Operators.
  • Unary Operators.
  • Bitwise Operators.
  • Shift Operators.
  • Ternary Operators.

Arithmetic Operators:

Arithmetic operators are used to performing arithmetic operations on operands.



Assignment Operators:

Assignment operators are used to assign values to the variables.



Comparison Operators:

Comparison Operators are used to comparing two values and perform an action on the basis of the result of that comparison. Whenever you use a comparison operator, the expression results in the boolean value true or false.



Logical Operator:

Logical Operator is used to evaluating operands and return a boolean value.



Unary Operators:

An operator that requires one operand is called a unary operator.


Bitwise Operators:

Bitwise operators are used to manipulate the data at bit level. The bitwise operators operate on the individual bits of their operands. The operand can be of various data types, such as int, float, short, long, char etc. 

Types:

  • Bitwise AND
  • Bitwise OR
  • Bitwise NOR
  • Bitwise XOR


Shift Operators:

A shift operator is used to shift the bits of its operands either to the left or the right.

Types:

  • Right shift operator(>>)
  • Left shift operator(<<)
  • Unsigned right shift operator(>>>)


Ternary Operators:

The ternary operator is used to evaluate an expression. The operator works on logical expression and two operands. It returns one of the two operands depending on the result of the expression.

Syntax of ternary operator:

Boolean_expression ? expression1 :expression 2

If Boolean_expression evaluates to true, expression 1 is returned, else expression 2 is returned.





Post a Comment

0 Comments