11th Class . IT(Information Technology) Skill Set 3 - Javascript. Sop-2
STD: 11th. Subject: IT(Information Technology)
Client Side Scripting (JavaScript)
Skill Set 3 - Javascript
SOP 2 : Create Javascript Program For The Following Using Appropriate Variables, Javascript Inbuilt Functions And Control Structures.
To accept two positive or negative numbers and check whether they are equal or
not.
To accept number and display square of it.
To check whether the accepted integer is multiple of 3 or multiple of 7.
Solution :
To accept two positive or negative numbers and check whether they are equal or not.
<!DOCTYPE html>
<html>
<head>
<title>sop2</title>
</head>
<body>
<h1> To accept two positive or negative numbers and check whether they are
equal or not </h1>
<script language=javascript>
var n1,n2
n1=prompt("Enter first number positive or negative","type here")
n2=prompt("Enter second number positive or negative ","type here")
if(n1==n2)
document.write(n1+ " and " + n2+" are equal")
else
document.write(n1+ " and " + n2+" are not equal")
</script>
</body>
</html>
Output:
To accept number and display square of it.
<!DOCTYPE html>
<html>
<head>
<title>sop2</title>
</head>
<body>
<h1> To accept a number and display square of it </h1>
<script language=javascript>
var n,sq
n=prompt("Enter any number","type here")
sq=n*n
document.write("Square = " +sq)
</script>
</body>
</html>
Output:
To check whether the accepted integer is multiple of 3 or multiple of 7.
<!DOCTYPE html>
<html>
<head>
<title>sop2</title>
</head>
<body>
<h1> To check whether the accepted integer is multiple of 3 or multiple
of 7 </h1>
<script language=javascript>
var n
n=prompt("Enter a number")
if((n%3==0)||(n%7==0))
document.write(n + " is multiple of 3 or 7 ")
else
document.write(n + " is not multiple of 3 or 7 ")
</script>
</body>
</html>
Output:
Comments
Post a Comment