Q.No.2 - Write an HTML code and use Javscript to multiply and divide two number which is given by user.
Sol.-
<!DOCTYPE html>
<html>
<head>
<title>Javascript</title>
</head>
<body>
<h1>Multiplication and Division calculator</h1>
Enter Your 1st No. : <input id="f1"><br><br>
Enter Your 2nd No. : <input id="f2"><br><br>
<button onclick="mul()">Multiply</button>
<button onclick="div()">Divide</button>
Result Here : <span id="result"></span>
<script >
function mul() {
var a=document.getElementById("f1").value;
var b=document.getElementById("f2").value;
var c= a*b ;
document.getElementById("result").innerHTML=c;
}
function div() {
var a=document.getElementById("f1").value;
var b=document.getElementById("f2").value;
var d = parseInt(a)/parseInt(b);
document.getElementById("result").innerHTML=d;
}
</script>
</body>
</html>
OUTPUT:
![](pr2-j2o.png)