 # Lesson 5: Performing Arithmetic Operations

JavaScript is not just a scripting language, it can also perform arithmetic operations. On top of that, it can interact with online users by receiving data from them, operate on the data and then displays the output to the users. The four basic arithmetic operators in JavaScript are shown in the following table:

Table 5.1 Arithmetic Operations
Operation Operator
Subtraction -
Multiplication *
Division /
Remainder %
Exponentiation **

For example, 13%5=3 and 4**2=42=16.

Let us construct our first arithmetic program in JavaScript. You can either use a text editor such as Notepad to type in the statements. You can also use Microsoft Frontpage or Dreamweaver to do the job. However, the best free editor I would recommend is Notepad++, which you can download from  https://notepad-plus-plus.org/ .

#### Example 5.1 A Simple Arithmetic Program

```
<Script>
var           Number1, // this is the first string input by the user
Number2 , // this is the second string input by the user
Num1 , // numeric value converted from Number1
Num2, // numeric value converted from Number2
sum,
difference ,
product,
quotient;
Num1=parseInt(Number1);
Num2=parseInt(Number2);
sum=Num1+Num2;
difference=Num1-Num2;
product=Num1*Num2;
quotient=Num1/Num2;
document.getElementById('sum').innerHTML=sum
document.getElementById('difference').innerHTML=difference;
document.getElementById('product').innerHTML=product;
document.getElementById('quotient').innerHTML=quotient;
</Script>
```
Click the Start button initiate the calculation.

```The sum is