Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
15 views2 pages

Practical 4

sdfrter gdhrtfg zedhy e4tnye fzs5ttttttttttttttttttttttttttttt
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views2 pages

Practical 4

sdfrter gdhrtfg zedhy e4tnye fzs5ttttttttttttttttttttttttttttt
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Practical No.

4
Name :- Roll no :-
Aim :- Develop JavaScript to implement functions.

INPUT :-
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initialscale=1.0">
<title>JavaScript Functions Example</title>
</head>
<body>
<h1>JavaScript Functions Example</h1>
<!-- Input fields for numbers -->
<input type="number" id="num1" placeholder="Enter first number">
<input type="number" id="num2" placeholder="Enter second number">
<button onclick="addNumbers()">Add</button>
<!-- Output for the result -->
<p id="result"></p>
<!-- JavaScript code embedded in the HTML -->
<script>
// Function to add two numbers and display the result
function addNumbers() {
// Get the values from the input fields
var number1 = parseFloat(document.getElementById('num1').value);
var number2 = parseFloat(document.getElementById('num2').value);
var sum = number1 + number2;
document.getElementById('result').innerText = 'The sum is: ' + sum;
}
</script>
</body>
</html>

OUTPUT :-

You might also like