You are on page 1of 2

Practical 1

/* 1. Write a program to read arithmetic expression


from user,evaluate it
and display answer using alert box */

<html>
<body>
<script lang="Javascript" type="text/javascript">

var a = Number(prompt('Enter value of A'));


var b = Number(prompt('Enter value of B'));
var result;
document.write("Value of A = " + a + " and B = " + b);

//ADDITION
result = a + b;
alert("Addition of a & b = " + result);

//SUBSTRACTION
result = a - b;
alert("Substraction of a & b = " + result);

//MULTIPLICATION
result = a * b;
alert("Multiplication of a & b = " + result);

//DIVISION
result = a / b;
alert("Division of a & b = " + result);
</script>
</body>
</html>
Practical 1

/* 2. WAP to accept name from user using prompt box


and display message in format "Good Morning Madam"
using alert box */

<html>
<body>
<script lang="Javascript" type="text/javascript">

var name = prompt("Enter your name");


alert("Good Morning " + name);

</script>
</body>
</html>

You might also like