-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
54 lines (54 loc) · 1.66 KB
/
index.html
File metadata and controls
54 lines (54 loc) · 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Calculator</title>
<link rel="stylesheet" href="cal.css">
<script>
function cal(){
var num1=document.getElementById('first').value;
var num2=document.getElementById('second').value;
var op=document.getElementById('operator').value;
if(op=='+'){
var res=parseInt(num1)+parseInt(num2);
}
else if(op=='-'){
var res=parseInt(num1)-parseInt(num2);
}
else if(op=='*'){
var res=parseInt(num1)*parseInt(num2);
}
else if(op=='/'){
var res=parseInt(num1)/parseInt(num2);
}
else if(op=='%'){
var res=parseInt(num1)%parseInt(num2);
}
document.getElementById('res').value=res;
}
</script>
</head>
<body>
<div class="container">
<div class="item">
<label for="">Enter First Number:
<input type="number" name="" id="first"></label>
<br> <br> <br>
<label for="">Enter Second Number:
<input type="number" name="" id="second"></label>
<br><br><br>
<select name="" id="operator">
<option value="+">+</option>
<option value="-">-</option>
<option value="*">x</option>
<option value="/">/</option>
<option value="%">%</option>
</select>
<button onclick="cal()">=</button>
<input type="text" name="" id="res">
</div>
</div>
</body>
</html>