<!DOCTYPE html>
<html>
<body>
<head>
<style>
.btn{
border:2px solid #000099;
width:20%;
padding:30px 30px;
}
bottun{
margin:10px;
padding:10px 10px;
}
.text3{
border-right:none;
}
</style>
</head>
<h2>calculator:-</h2>
N1:<input id="n1" type="number"><br><br>
N2:<input id="n2"type="number"><br><br>
RE:<span id="r">__________</span><br><br>
<div class="btn">
<button onclick="sum()">+</button>
<button onclick="sub()">-</button>
<button onclick="mul()">*</button><br><br>
<button onclick="div()">/</button>
<button onclick="mod()">%</button>
<button onclick="equ()">==</button>
</div>
<script>
function sum() {
var d,e,v;
d=Number(document.getElementById("n1").value);
e=Number(document.getElementById("n2").value);
v=d+e;
document.getElementById("r").innerHTML=v;
}
function sub() {
var d,e,v;
d=Number(document.getElementById("n1").value);
e=Number(document.getElementById("n2").value);
v=d-e;
document.getElementById("r").innerHTML=v;
}
function mul() {
var d,e,v;
d=Number(document.getElementById("n1").value);
e=Number(document.getElementById("n2").value);
v=d*e;
document.getElementById("r").innerHTML=v;
}
function div() {
var d,e,v;
d=Number(document.getElementById("n1").value);
e=Number(document.getElementById("n2").value);
v=d/e;
document.getElementById("r").innerHTML=v;
}
function mod() {
var d,e,v;
d=Number(document.getElementById("n1").value);
e=Number(document.getElementById("n2").value);
v=d%e;
document.getElementById("r").innerHTML=v;
}
function equ() {
var d,e,v;
d=Number(document.getElementById("n1").value);
e=Number(document.getElementById("n2").value);
v=d==e;
document.getElementById("r").innerHTML=v;
}
</script>
</body>
</html>
No comments:
Post a Comment