Perl Arithmetic Operators

PERLServer Side ProgrammingProgramming Scripts

Assume variable $a holds 10 and variable $b holds 20, then following are the Perl arithmetic operators −

Sr.No.Operator & Description
1+ ( Addition )
Adds values on either side of the operator
Example− $a + $b will give 30
2- (Subtraction)
Subtracts right-hand operand from the left-hand operand
Example− $a - $b will give -10
3* (Multiplication)
Multiplies values on either side of the operator
Example− $a * $b will give 200
4/ (Division)
Divides left-hand operand by right-hand operand
Example− $b / $a will give 2
5% (Modulus)
Divides left-hand operand by right-hand operand and returns the remainder
Example− $b % $a will give 0
6** (Exponent)
Performs exponential (power) calculation on operators
Example− $a**$b will give 10 to the power 20
raja
Published on 29-Nov-2019 06:10:13
Advertisements