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

Is javascript frontend or backend?

834


What is the difference between undefined value and null value?

949


What are the primitive data types in JavaScript?

976


What is a class in javascript?

886


what is function of stdio.h

2436


What value does prompt() return if the user clicked the cancel button?

820


How do you organize your JavaScript code?

1023


What is difference between api and library?

939


Create an array in javascript with a list of 4 colors, assign that array to the variable, ‘colors’.

858


What are javascript objects?

916


How do I open javascript?

894


Is javascript event driven?

867


What exactly does javascript do?

989


What is javascript and its advantages?

949


What is singleton class in javascript? Explain

935