Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

Write a javascript program to make a simple calculator

Answer Posted / ruchi goswami

<html>
<head>
<link rel="stylesheet" type="text/css" href="css2.css">
<title> calculator </title>
</head>

<body>
<div id="wrap">
<h1> Calculator </h1>
<b> enter first number </b>
&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp
<b> enter second number </b>
<form action="">
<input type="text" name="firstnum" id="first">
&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp
<input type="text" name="lastnum" id="second">
</form>

<br> </br>
<button onclick="sum()"> + </button>
&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp
<button onclick="sub()"> - </button>
&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp
<button onclick="mul()"> * </button>
&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp
<button onclick="divi()"> / </button>
<br> </br>
<input type="text" id="result">




<p id="demo"></p>
<script>
function sum()
{
var a = Number(document.getElementById("first").value);
var b = Number(document.getElementById("second").value);
c = a+b;
document.getElementById("result").value = c;

}
function sub()
{
var a = Number(document.getElementById("first").value);
var b = Number(document.getElementById("second").value);
c = a-b;
document.getElementById("result").value = c;

}

function mul()
{
var a = Number(document.getElementById("first").value);
var b = Number(document.getElementById("second").value);
c = a*b;
document.getElementById("result").value = c;

}

function divi()
{
var a = Number(document.getElementById("first").value);
var b = Number(document.getElementById("second").value);
c = a/b;
document.getElementById("result").value = c;

}
</script>


</div>
</body>
</html>

Is This Answer Correct ?    15 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How to create arrays in javascript?

963


Is javascript safe to download?

854


What is the use of Void(0)?

1057


What is a nan value?

939


What is the difference between "var" and "let" keywords?

938


How to create an array in javascript?

1051


Is javascript server side or client side?

944


What are global variables? How are these variable declared and what are the problems associated with using them?

958


How are DOM utilized in JavaScript?

1103


how can i change colour of a image in aspx file?

1985


What are the seven data types of javascript?

1031


Is javascript multi-threaded or single-threaded?

948


Who created npm?

914


What is innertext javascript?

957


What is the similarity between the 1st and 2nd statement?

957