JavaScript

May 16, 2023

How to use Arithmetic Operators JavaScript Language

Program to use Arithmetic Operator (-, +, *, **, /, %, – -, ++) Javascript Language


let a = 5;
let b = 3;
let c;

//subtraction oprater (-)
c = a - b;
console.log('c = ', c);
// Output c =  2

//addition oprater (+)
c = a + b;
console.log('c = ', c);
// Output c =  8


//multiplication oprater (*)
c = a * b;
console.log('c = ', c);
// Output c = 15

//exponentiation oprater (**)
c = a ** b;
console.log('c = ', c);
// Output c = 125

//division oprater (/)
c = a / b;
console.log('c = ', c);
// Output c =  1.6666666666666667

//modulus (remainder) oprater (%)
c = a % b;
console.log('c = ', c);
// Output c = 2

//decrement oprater (--)
console.log('a = ',a)
console.log('--a = ',--a)
console.log('a-- = ',a--)
// Output a =  5 , --a = 4 , a-- = 4


//increment oprater (++)
console.log('b = ',b)
console.log('++b = ',++b)
console.log('b++ = ',b++)
// Output b = 3 , ++b = 4 , b++ = 4

Output


c =  2
c =  8
c =  15
c =  125
c =  1.6666666666666667
c =  2
a =  5
--a =  4
a-- =  4
b =  3
++b =  4
b++ =  4

by : Suhel Akhtar

Quick Summary:

Arithmetic Operators JavaScript program