You are on page 1of 7

Samarth Polytechnic, Belhe

DEPARTMENT OF COMPUTER ENGINEERING

Subject: Client Side Scripting Subject Code:22519


Semester: 5th Course: Computer Engineering
Name of Subject Teacher: Kshirsagar S.B. Laboratoer No: L001b
Name of Student: Shekhar Dattatray Jadhav Roll Id :29

Experiment No: 1
Title of Experiment Write simple Javascript with HTML for arithmetic expression evaluation and
message printing.

Theory: JavaScript is the programming language of HTML and the Web.

JavaScript Arithmetic Operators


Arithmetic operators perform arithmetic on numbers (literals or variables).

Operator Description

+ Addition

- Subtraction

* Multiplication

** Exponentiation

/ Division

% Modulus (Remainder)

++ Increment
A typical arithmetic operation operates on two numbers.
The two numbers can be literals:

Operators and Operands

The numbers (in an arithmetic operation) are called operands.


The operation (to be performed between the two operands) is defined by an operator.
Syntax:-

var x = 5; // assign the value 5 to x


var y = 2; // assign the value 2 to y
var z = x + y; // assign the value 7 to z (x + y)

Example:-

<p id="demo"></p>

<script>

var x = 5;

var y = 2;

var z = x + y;

document.getElementById("demo").innerHTML = z;

</script>

Program:

<html>
<head>
<title>TODO supply a title</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script type="text/JavaScript" src="sali.js">
</script>
</head>
<body>
</body>
</html>

Js file:-

var m=50, n=4; function add()


{

var c; c=m+n;
document.write("Addition is:"+c);
}
var p=6 , q=60;
function sub()
{
var k; k=p-q;
document.write("subtraction is:"+k);
}
var j=54 , h=1;
function mul()
{
var o; o=j*h;
document.write("multiplication is:"+o);
}
var x= 54 , y=1;
function div()
{
var m; m=x/y;
document.write("Division is:"+m);
}

var i=parseInt(prompt("1.add<br>2.sub<br>3.mul<br>4.div")); switch(i)


{
case 1:add(); break;
case 2:sub(); break;
case 3:mul(); break;
case 4:div(); break;
default:document.write("wrong choice "); break;
}

OUTPUT :-
Grade and C (4M) P (4M) A (2M) Total ( 10 M) Dated Sign
Dated

Signature of
Teacher

You might also like