Saturday 25 January 2014

example program for arithmatic operators

<!--Arthemetical Operators-->
<html>
<head>
<title>
Arithmetic Operations
</title>
<script language="javascript">
function add()
{
document.form1.result.value=parseFloat(document.form1.first.value)+
parseFloat(document.form1.second.value)
}
function sub()
{
document.form1.result.value=parseFloat(document.form1.first.value)-
parseFloat(document.form1.second.value) }
function mul()
{
document.form1.result.value=parseFloat(document.form1.first.value)*
parseFloat(document.form1.second.value)
}
function div()
{
document.form1.result.value=parseFloat(document.form1.first.value)/
parseFloat(document.form1.second.value)
}
function exit()
{
window.close()
}
</script>
</head>
<body bgcolor=chocolate>

<center>
<font color=navy size=5>
<form name="form1">
Enter First Number :<input type="text" name="first" size="10">
<br> <br>
Enter Second Number :<input type="text" name="second" size="10">
<br> <br>
Result :<input type="text" name="result" size="10" readonly>
<br> <br>
<input type="button" value="Add" onClick="add()" size="100">
<input type="button" value="Sub" onClick="sub()" size="100">
<input type="button" value="Mul" onClick="mul()" size="100">
<input type="button" value="Div" onClick="div()" size="100">
<br> <br> <br>
<input type="button" value="Exit" onClick="exit()" size="100">
<input type="reset" value="Reset" onClick='document.form1.first.focus()' >
</form>
</body> </html>

No comments:

Post a Comment