JavaScripts Codes (Pract 6-Pract8)
JavaScripts Codes (Pract 6-Pract8)
SOP 5 : Create JavaScript program for the following using appropriate variables, JavaScript inbuilt
functions and control structures.
To accept integer and display the result by multiplying it with 3.
<!doctype html>
<html>
<head>
<title> Practical 5</title>
</head>
<body bgcolor="yellow">
<h1> Program to accept integer and multiple it with 3</h1>
<script language="javascript">
var i, mul;
i=prompt("Enter integer=");
mul=i*3;
document.write("<h1> Integer entered is"+i);
document.write("<h1> Multiple of 3 is"+mul);
</script>
</body>
</html>
Conclusion- A JavaScript program is implemented to accept integer and display its multiple with 3.
Output
SOP 6 : Create JavaScript program for the following using appropriate variables, JavaScript inbuilt
functions and control structures.
To calculate Area of a Circle.
<!doctype html>
<html>
<head>
<title> Practical 6</title>
</head>
<body bgcolor="cyan">
<h1> Program to calculate Area of a Circle</h1>
<script language="javascript">
var r, area;
r=prompt("Enter the radius a circle=");
area=3.14*r*r;
document.write("<h1> Radius entered is"+r);
document.write("<h1> Area of the Circle is "+area);
</script>
</body>
</html>
Conclusion- A JavaScript program is implemented to accept radius and calculate area of a circle.
SOP 7 : Create JavaScript program for the following using appropriate variables, JavaScript inbuilt
functions and control structures.
To accept number and display square of it.
<!doctype html>
<html>
<head>
<title> Practical 7</title>
</head>
<body bgcolor="pink">
<h1> Program to accpet a number and display its square</h1>
<script language="javascript">
var no,sqr;
no=prompt("Enter the number=");
sqr=no*no;
document.write("<h1> Number entered is " +no);
document.write("<h1> Square of the number is "+sqr);
</script>
</body>
</html>
Conclusion- A JavaScript program is implemented to accept number from the user and display its
square.
SOP 8 : Create JavaScript program for the following using appropriate variables, JavaScript inbuilt
functions and control structures.
To accept a number and check if the number is Even or Odd.
<!doctype html>
<html>
<head>
<title> Practical 8</title>
</head>
<body bgcolor="green">
<h1> Program to accpet a number and check if the number is Even or Odd/h1>
<script language="javascript">
var no;
no=prompt("Enter the number=");
if(no%2==0)
alert("Number is Even");
else
alert("Number is Odd");
</script>
</body>
</html>
Conclusion- A JavaScript program is implemented to check if the number is Even or Odd.