-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpractical_1.html
More file actions
33 lines (30 loc) · 1.17 KB
/
Copy pathpractical_1.html
File metadata and controls
33 lines (30 loc) · 1.17 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
# Madanraj sagar
<!DOCTYPE html>
<html>
<head>
<title>Arithmetic Expression Evaluator</title>
</head>
<body>
<input type="number" id="num1" placeholder="Enter first number">
<input type="number" id="num2" placeholder="Enter second number">
<button onclick="calculate()">Calculate</button>
<p id="result"></p>
<script>
function calculate() {
// Get the values from the input fields
let num1 = parseInt(document.getElementById("num1").value);
let num2 = parseInt(document.getElementById("num2").value);
// Perform the calculation
let sum = num1 + num2;
let difference = num1 - num2;
let product = num1 * num2;
let quotient = num1 / num2;
// Display the results
document.getElementById("result").innerHTML = "Sum: " + sum + "<br>";
document.getElementById("result").innerHTML += "Difference: " + difference + "<br>";
document.getElementById("result").innerHTML += "Product: " + product + "<br>";
document.getElementById("result").innerHTML += "Quotient: " + quotient;
}
</script>
</body>
</html>