Std XI I.T || Skill Set 3 – JavaScript || SOP2
SOP2: 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.
<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>
- To accept a 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>
- 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>
Comments
Post a Comment