CodesJava

Easy learning with example program codes

Javascript arithmetic operators tutorial


JavaScript Arithmetic Operators:

Arithmetic operators are used to perform arithmetic operations.

JavaScript Arithmetic Operators List:

Operator Description Example
+ Addition 30+20 = 50
Subtraction 30-10 = 20
* Multiplication 10*10 = 100
/ Division 50/10 = 5
% Modulus (Remainder) 50%7 = 1
++ Increment var a=10; a++; Result into a = 11
Decrement var a=10; a–; Result into a = 9

JavaScript Arithmetic Operators Example:

<html>
<head>
<script type="text/javascript">
            var a = 33;
            var b = 10;
            var c = "Test";
            var linebreak = "<br />";
 
            document.write("a + b = ");
            result = a + b;
            document.write(result);
            document.write(linebreak);
 
            document.write("a - b = ");
            result = a - b;
            document.write(result);
            document.write(linebreak);
 
            document.write("a / b = ");
            result = a / b;
            document.write(result);
            document.write(linebreak);
 
            document.write("a % b = ");
            result = a % b;
            document.write(result);
            document.write(linebreak);
 
            document.write("a + b + c = ");
            result = a + b + c;
            document.write(result);
            document.write(linebreak);
 
            a = ++a;
            document.write("++a = ");
            result = ++a;
            document.write(result);
            document.write(linebreak);
 
            b = --b;
            document.write("--b = ");
            result = --b;
            document.write(result);
            document.write(linebreak);
      </script>
</head>
   <body>
   </body>
</html>

Try it:

JS Bin on jsbin.com
 



Industrial Training

We offers Placement Oriented Training on Java, Spring, JSF, Hibernate, PHP, AngularJS, Angular 4, PLSQL, Oracle BI Publisher etc. We also provides Online training, please mail us at hr@codesjava.com.

Development

We also provides the Development services for Website Development , Java Development, PHP Development, Android App Development etc. You can contact us on hr@codesjava.com.

Copyright © 2019 CodesJava DMCA.com Protection Status SiteMap Reference: Java Wiki