0% found this document useful (0 votes)
23 views

8770670-Class8 Javascript Worksheet

Uploaded by

D I W A K A R
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views

8770670-Class8 Javascript Worksheet

Uploaded by

D I W A K A R
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

INDIAN SCHOOL AL WADI AL KABIR

Class: VIII Department: Computer Science Year: 2023-2024

Worksheet with Topic: DYNAMIC WEBPAGES IN Solve these


solutions HTML5 questions in the
laboratory
PRACTICAL WORKSHEET

Practical Lab Programs in Javascript


1. Write a JavaScript program to swap the value of two variables without
using a third variable. Take the value of both variables from the user.
2. Write a JavaScript program to calculate the area of a square
3. Write a Javascript program to convert Kilometers to centimetrs
4. Develop a JavaScript program to perform following arithmetic operations:
addition, subtraction, multiplication and division.

Solutions
1)Write a JavaScript program to swap the value of two variables without using
a third variable. Take the value of both variables from the user.
<html>
<head>
<title>Javascript</title></head>
<body>
<script type="text/javascript">
var x=parseInt(prompt("Enter first number"));
var y=parseInt(prompt("Enter second number"));
x = x+y ;
y = x -y ;
x = x -y ;
document.write("x =");
document.write(x);
document.write("<br>");
1| 7- 0 5 - 2 0 2 3 / P R E P A R E D B Y : T e s s M a r y T h o m a s / I C T D e p t .
document.write("y =");
document.write(y);
</script>
</body>
</html>
2) Write a Javascript program to calculate the area of a square
<html>
<head>
<title>Area of square</title></head>
<body>
<script type="text/javascript">
var s=parseInt(prompt("enter the side of square"));
var area;
area=s*s;
document.write("Area of square=");
document.write(area);
</script>
</body></html>
3)Write a Javascript program to convert Kilometers to centimetrs
<html>
<head>
<title>javascript</title></head>
<body>
<script type="text/javascript">
var km=parseInt(prompt("enter the value in Kilometer"));
var cm;
cm=100000*km;
document.write("kilometre to centimetre=");
document.write(cm);
</script>
</body>
</html>

2| 7- 0 5 - 2 0 2 3 / P R E P A R E D B Y : T e s s M a r y T h o m a s / I C T D e p t .
4 )Develop a JavaScript program to perform following arithmetic operations:
addition, subtraction, multiplication and division.
<html>
<head>
<title>Arithmetic operators in Javascript</title></head>
<body>
<script type="text/javascript">
var a=parseInt(prompt("enter first number"));
var b=parseInt(prompt("enter second number"));
var sum;
var difference;
var product;
var quotient;
sum=a+b;
difference=a-b;
product=a*b;
Quotient=a/b;
document.write("Sum= ");
document.write(sum);
document.write("<br>");
document.write("Difference =");
document.write(difference);
document.write("<br>");
document.write("Product=");
document.write(product);
document.write("<br>");
document.write("Quotient=");
document.write(quotient);
</script>
</body>
</html>

3| 7- 0 5 - 2 0 2 3 / P R E P A R E D B Y : T e s s M a r y T h o m a s / I C T D e p t .

You might also like