-
Notifications
You must be signed in to change notification settings - Fork 0
/
task16.html
52 lines (41 loc) · 1.47 KB
/
task16.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
Q16) : Take two number through keyboard and perform arithmatic operation using Functions:
<br><br>
<input type="text" name="enter 1st number" id="no1">
<input type="text" name="enter 2nd number" id="no2">
<button onclick="myFunction()">Check</button>
<script>
function myFunction(){
var number_1 = document.getElementById('no1').value;
var number_2 = document.getElementById('no2').value;
document.write('Add of Two No: ' + add(number_1,number_2));
document.write('<br>');
document.write('Sub of Two No: ' + sub(number_1,number_2));
document.write('<br>');
document.write('div of Two No: ' + div(number_1,number_2));
document.write('<br>');
document.write('prod of Two No: ' + prod(number_1,number_2));
}
function add (x,y){
var a = parseInt(x) + parseInt(y);
return a;
}
function sub (x,y){
return x -= y;
}
function div (x,y){
return x /= y;
}
function prod (x,y){
return x *= y;
}
</script>
</body>
</html>