ES6 - Arithmetic operators


Advertisements

Assume the values in variables a and b are 10 and 5 respectively.

Example

var num1 = 10
var num2 = 2
var res = 0
res = num1+num2
console.log("Sum: "+ res);
res = num1-num2;
console.log("Difference: "+res)
res = num1*num2
console.log("Product: "+res)
res = num1/num2
console.log("Quotient: "+res)
res = num1%num2
console.log("Remainder: "+res)
num1++
console.log("Value of num1 after increment "+num1)
num2--
console.log("Value of num2 after decrement "+num2)

The following output is displayed on successful execution of the above program.

Sum: 12
Difference: 8
Product: 20
Quotient : 5
Remainder: 0
Value of num1 after increment: 11
Value of num2 after decrement: 1
Advertisements