Airthmetic operator in JavaScript

Airthmetic operator in JavaScript

The number which is called operands

The operations between two operands are defined by operator

Arithmetic operators are

Addition(+)

the operations between two or more operands perform an Addition operation ( + )

Example :

<!DOCTYPE html>
<html>
 <body>
  <script>
   var a=18;
   var b=20;
   document.write(a+b);
  </script>
 </body>
</html>

Output: 38

Or

<!DOCTYPE html>
<html>
 <body>
  <script>
   var a=18;
   var b=20;
   var c=a+b;
   document.write(c);
  </script>
 </body>
</html>

Output : 38

• Subtraction(-)

the operations between two or more operands perform an Subtraction operation ( – ).

Example:

<!DOCTYPE html>
<html>
 <body>
  <script>
   var a=18;
   var b=20;
   var c=a-b;
   document.write(c);
  </script>
 </body>
</html>

Output: -2

• Multiplication(%)

the operations between two or more operands perform an Multiplication operation ( * ).

Example:

<!DOCTYPE html>
<html>
 <body>
  <script>
   var a=18;
   var b=20;
   var c=a*b;
   document.write(c);
  </script>
 </body>
</html>

Output: 360

• Division (%)

the operations between two or more operands perform an Division operation ( %).

Example :

<!DOCTYPE html>
<html>
 <body>
  <script>
   var a=18;
   var b=20;
   var c=a/b;
   document.write(c);
  </script>
 </body>
</html>

Example: 0.9

• Exponential (**)

Exponential it raise the first operand to the power of second operands.

Example:

<!DOCTYPE html>
<html>
 <body>
  <script>
   var a=2;
   var b=3;
   var c=a**b;
   document.write(c);
  </script>
 </body>
</html>

Output: 8

• Modules (%)

Example:

<!DOCTYPE html>
<html>
 <body>
  <script>
   var a=20;
   var b=3;
   var c=a%b;
   document.write(c);
  </script>
 </body>
</html>

Output : 2

• Increment (++)

Example:

<!DOCTYPE html>
<html>
 <body>
  <script>
   var a=20;
   document.write(++a);
  </script>
 </body>
</html>

Output : 21

• Decrement(–)

Example:

<!DOCTYPE html>
<html>
 <body>
  <script>
   var a=20;
   document.write(--a);
  </script>
 </body>
</html>

Output: 19