2. JavaScript Program to calculate Multiplication and Division of two numbers.
How does this program work?
- In this program you will learn about how to find Multiplication and Division of two numbers using JavaScript.
- Initially The integer entered by the user is stored in two variables a,b.
- After that by using the given formula you will get the output.
Here is the code
<html>
<head>
<title>JavaScript Program to find Multiplication and Division of two numbers</title>
</head>
<body>
<table>
<tr>
<td> <input type="text" name="a" id="first" placeholder="Enter first number"> </td>
</tr>
<tr>
<td> <input type="text" name="b" id="second" placeholder="Enter second number"> </td>
</tr>
<tr>
<td> <button onclick= "mul()" >Submit</button> </td>
</tr>
</table>
<div id="mul"></div>
<div id= "div"></div>
</body>
<script type="text/javascript">
function mul()
{
var a,b,Mul,Div;
a = parseInt(document.getElementById ("first").value);
b = parseInt(document.getElementById ("second").value);
Mul = a*b; //Multiplication of two numbers
Div = a/b; //Division of two numbers
//To print the result document.getElementById ("mul").innerHTML ="Multiplication of "+a+"*"+b+"= "+Mul;
document.getElementById ("div").innerHTML ="Division of "+a+"/"+b+"= " +Div;
}
</script>
</html>