Breaking News
yeni film izle hd film seyret film izle

Arithmetic Operators In Java Script

Arithmetic operators are used in daily life, like adding , subtracting, multiplying , dividing etc. The arithmetic operators are supported by JavaScript are :
 
Operator Description
+ Addition
Subtraction
* Multiplication
/ Division
% Modulus
++ Increment
Decrement

 

Example
 
<html>

<head>

</head>

<body>

<script type=”text/javascript”>

var a=40; var b = 50; var c= 5;

var d; d = a+b document.write(“<br> Value of a is : “+a);

document.write(“<br> Value of b is : “+b);

document.write(“<br> Value of c is : “+c);

document.write(“<br>Sum of a & b is : “+d);

d=b-c; document.write(“<br>Difference of b & c is : “+d);

d= a*c;

document.write(“<br>Multiplication of a & c is : “+d);

d=b/c;

document.write(“<br>Quotient of Division of b & c is : “+d);

d = a%c; document.write(“<br>Remainder of Division of a & c is : “+d);

a++; b–;

document.write(“<br>Value of A is now “+a);

document.write(“<br>Value of b is now “+b);

</script >

</body>

</html>

 
 
Understanding the program:
Variable d store the result of every arithmetic operation with the two operands and displays the result. Division operator (/) returns the quotient of the division like 40/5= 8 but modulus (%) returns the remainder of the division like 40%5 = 0.the value of a will get increment with one a++ is equal to a=a+1and b– is equal to b = b-1. so the value of a was 40 it got incremented with one and became 41 while the value of b was 50 and got decremented with one and became 49.
 
Output is:
 
Value of a is: 40
Value of b is: 50
Value of c is: 5
Sum of a & b is: 90
Difference of b & c is: 45
Multiplication of a & c is: 200
Quotient of Division of b & c is: 10
Remainder of Division of a & c is: 0
Value of A is now 41
Value of b is now 49

Check Also

Recursive Functions In Java Script

A function which calls itself, is called a recursive function. When A function calls itself …