PHP Arithmetic Operator

By | March 29, 2014
0
0



Arithmetic operators

Arithmetic operators are used to perform elementary mathematical calculation and are used when value of variable declare in integer type.

Name Example Output
Addition $a+$b The sum of $a and $b
Subtraction $a-$b The difference between $a and $b
Multiplication $a*$b The product of $a and $b
Division $a/$b The quotient of $a and $b
Modules $a%$b The remainder after dividing $a and $b

Let us look at some examples for a better understanding of arithmetic operators:

Addition
$a = 3;
$b = 6;
$c = $a+$b ; // The value of $c is now 9.
Subtraction
$a = 11;
$b = 2;
$c = $a-$b; //The value of $c is now 9.
Multiplication
$a = 3;
$b = 3;
$c = $a*$b; //The value of $c is now 9.
Division
$a = 18;
$b = 2;
$c = $a/$b ; //The value of $c is 9.
Modules
$a = 9;
$b = 3;
$c = $a%$b; //The value of $c is now 0.

Leave a Reply

Your email address will not be published. Required fields are marked *