Arithmetic Operator



Write a JavaScript code to implement arithmetic operators.

<html>
  <head>
    <title>Arithmetic Operator</title>
      <script>

        var x = 5, y = 10, z = 15;

        document.write ("x + y =" + (x + y)); //returns 15
        document.write ("<br>");

        document.write ("y - x =" + (y - x)); //returns 5
        document.write ("<br>");

        document.write ("x * y =" +(x * y)); //returns 50
        document.write("<br>");

        document.write ("y / x =" + (y / x)); //returns 2
        document.write("<br>");

        document.write ("x % 2 =" + (x % 2)); //returns 1
        document.write ("<br>");

        document.write (" x++ =" + (x++)); //returns 5
        document.write ("<br>");

        document.write (" x-- =" + (x--)); //returns 4

      </script>
  </head>
<body>       
</body>
</html>

Output:

x + y =15
y - x =5
x * y =50
y / x =2
x % 2 =1
x++ =5
x-- =6