<html>
<head>
<title>Type Casting Example</title>
</head>
<body>
<h2>Simple Addition Example</h2>
First number: <input type="text" id="num1"><br><br>
Second number: <input type="text" id="num2"><br><br>
Third number: <input type="text" id="num2"><br><br>
<button onclick="add()">Add</button>
<script>
function add() {
// Input values ko read karna
a = document.getElementById("num1").value;
b = document.getElementById("num2").value;
c=document.getElementById("num2").value
// String to number conversion
a = Number(a);
b = Number(b);
c = Number(c);
// Addition
sum = a + b+c;
// Result show
document.write("Sum: " + sum);
}
</script>
</body>
</html>
0 comments:
Post a Comment