Java – Arithmetic Operators

Home/Java - Tutorial/Java - Operators/Java – Arithmetic Operators
Java – Arithmetic Operators 2017-06-13T09:31:29+00:00

Arithmetic operators in java:

EX.

 


Output :
…………..Arithmetic operators……………..
<——-Basic Arithmetic operators——->
Addition of a and b : a + b = 10 + 3 = 13
Subtraction of a and b : a – b = 10 – 3 = 7
Multiplication of a and b : a * b = 10 * 3 = 30
Division of a and b : a / b = 10 / 3 = 3
Modulus of a and b : a % b = 10 % 3 = 1
<——-Increment Operator——->
Before Post-Increment of c = 20
Post-Increment of c : c++ = 20++ = 20
After Post-Increment of c = 21
Before Pree-Increment of d = 30
Pree-Increment of d : ++d = ++30 = 31
After Pree-Increment of d = 31
<——-Decrement Operator——->
Before Post-Decrement of c = 40
Post-Decrement of e : e– = 40– = 40
After Post-Decrement of e = 39
Before Pree-Decrement of f = 50
Pree-Decrement of f : –f = –50 = 49
After Pree-Decrement of f = 49
<——-Assignment Operators——->
Addition Assignment of a and b : a += b means 10+=3 => a = a + b => a = 10 + 3 = 13
Subtraction Assignment of i and j : i -= j means 10-=5 => i = i – j => i = 10 – 5 = 5
Multiplication Assignment of m and l : m *=l means 30*=3 => m = m * l => m = 30 * 3 = 90
Division Assignment of o and v : o /= v means 25/=6 => o = o / v => o = 25 / 6 = 4
Modulus Assignment of z and r : z %= r means 27%=8 => z = z % r => z = 27 % 8 = 3

Prev Next