In order to understand the working of an Arithmetic Operator let us assume, there are two variable a and b with initial values 2 and 6 respectively, then:
|Arithmetic Operators||Description and Examples|
|Addition (+)||It adds two operands.|
Example: a + b produces the value 8.
|Subtraction (-)||It subtract the value of the second operand from the value of the first operand.|
Example: a – b produces a value -4.
|Multiplication (*)||It multiply the values of both operands.|
Example: a*b produces the value 12.
|Division (/)||It divides the numerator by denominator.|
Example: b/a produces the value 3.
|Modulus (%)||It return the remainder in an integer division.|
Example: b%a produces the value 0.
|Increment (++)||It increases the integer value of an operand by 1.|
Example: a++ will give 3.
|Decrement (–)||It reduces the integer value of an operand by 1.|
Example: a– will give 1.
Note: Addition arithmetic operator is used to add two numbers, while it is used to concatenate two strings.
Example on Arithmetic Operators
Addition of 2 and 6 is = 8
Subtraction of 2 and 6 is = -4
Multiplication of 2 and 6 is = 12
Division of 2 and 6 is = 3
Modulus of 2 and 6 is = 0
In case you find any kind of error like typing error, spelling mistakes, incorrect grammar, incorrect information or any other mistakes. Please feel free to write to us at: firstname.lastname@example.org.