An Operator is a function that acts on two or more values and returns a value. The most commonly used operators are special symbols like + for addition, - for subtraction. The variables that an operator acts on are called operands.


x+y = 30;
In the above example, + is the operator that adds the two operands x and y together.

 Types of Operators

 Arithmetic Operators

An arithmetic operator operates on two numeric values and returns a single numeric value.


<op1> <Operator> <op2>

Where <op1> and <op2> are numeric expressions.

+addition of <op1> and <op2>
-subtracts <op2> from <op1>
*multiplies <op1> and <op2>
/divides <op1> by <op2>
%remainder when dividing <op1> by <op2>

 Relational Operators

A relational operator compares two values and returns a Boolean expression (either true or false) depending on the two values' relationship.


5 > 4 returns true.
233.6 < 94.22 returns false.


<op1> <Operator> <op2>

><op1> is greater than <op2>
>=<op1> is greater than or equal to <op2>
<<op1> is less than <op2>
<=<op1> is less than or equal to <op2>
==<op1> is equal to <op2>
!=<op1> is not equal to <op2>

 Conditional Operators

A conditional operator operates on a Boolean expression. You can write complex decision logic by combining relational operators and conditional operators.


<boolean expression> && <boolean expression>
<boolean expression> || <boolean expression>
! <boolean expression>

&&Both the left and right boolean expressions are true
llAtleast one of the boolean expression is true
!boolean expression is false

Share this post : FacebookTwitter

Still can't find what you're looking for?

Write to us: support@zohodeveloper.com