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

0% found this document useful (0 votes)
31 views3 pages

Assignment 1

This document contains code for an HTML page with JavaScript functions to perform basic arithmetic operations - addition, subtraction, multiplication, and division. The code defines functions to calculate each operation that get number values from input fields, perform the calculation, and output the result to a third input field. The HTML includes a form with number inputs and buttons to call each function.
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)
31 views3 pages

Assignment 1

This document contains code for an HTML page with JavaScript functions to perform basic arithmetic operations - addition, subtraction, multiplication, and division. The code defines functions to calculate each operation that get number values from input fields, perform the calculation, and output the result to a third input field. The HTML includes a form with number inputs and buttons to call each function.
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/ 3

Assignment 1

Code:-
<html>
<head>
<title> Operators </title>

<script>
function add()
{
var a,b,sum;
a=parseInt(document.getElementById("num1").value);
b=parseInt(document.getElementById("num2").value);
sum=a+b;
document.getElementById("num3").value=("Addition is "+sum);
}
function sub()
{
var a,b,sub;
a=parseInt(document.getElementById("num1").value);
b=parseInt(document.getElementById("num2").value);
sub=a-b;
document.getElementById("num3").value=("Subtraction is "+sub);
}
function mult()
{
var a,b,mult;
a=parseInt(document.getElementById("num1").value);
b=parseInt(document.getElementById("num2").value);
mult=a*b;
document.getElementById("num3").value=("Multiplication is "+mult);
Assignment 1
}
function div()
{
var a,b,div;
a=parseInt(document.getElementById("num1").value);
b=parseInt(document.getElementById("num2").value);
div=a/b;
document.getElementById("num3").value=("Division is "+div);
}

</script>
<style>
form{
border:2px solid black;
width:200px;
height:fit-content;
padding:20px;
margin:auto;
margin-top:150px;
}
</style>
</head>
<body style="text-align:center;">
<form>
<h2>Arithmatic Operations</h2>

<input type="text" id="num1" placeholder="Enter first no" class="txt1">


<br>
<br>
Assignment 1
<input type="text" id="num2" placeholder="Enter second no" class="txt2">
<br>
<br>
<input type="text" id="num3" class=txt3>
<br>
<br>
<input type="button" value="Add" onclick="add()">
<input type="button" value="Sub" onclick="sub()">
<input type="button" value="Mult" onclick="mult()">
<input type="button" value="Div" onclick="div()">

</form>
</body>
</html>

Output:-

You might also like