11th Class . IT(Information Technology) Skill Set 3 - Javascript. Sop-1

 

STD: 11th.   Subject: IT(Information Technology)

Client Side Scripting (JavaScript)

Skill Set 3 - Javascript



SOP 1 : 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. 
 To accept two integers and display larger number of them. 
 To check whether, user entered number is positive or negative.



Solution : 

 To accept integer and display the result by multiplying it with 3. 

<!DOCTYPE html>
<html>
<head>
<title>sop1</title>
</head>
<body>
<h1>To accept integer and display the result by multiplying it with 3</h1>
<script language=javascript>
var num,ans
num=prompt("Enter a number")
ans=num*3
document.write("Answer = "+ans)
</script>
</body>
</html>

Output:







 To accept two integers and display larger number of them. 

<!DOCTYPE html>
<html>
<head>
<title>sop1</title>
</head>
<body>
<h1> To accept two integers and display larger number of them </h1>
<script language=javascript>
var n1,n2
n1=prompt("Enter first number","type here")
n2=prompt("Enter second number","type here")
if(n1>n2)
document.write(n1+ " is the greater number")
else
document.write(n2+ " is the greater number")
</script>
</body>
</html>

Output:






 To check whether, user entered number is positive or negative.

<!DOCTYPE html>
<html>
<head>
<title>sop1</title>
</head>
<body>
<h1> To check whether user entered number is positive or negative </h1>
<script language=javascript>
var n
n=prompt("Enter a number","type here")
if(n>0)
document.write(n+ " is positive number")
else
document.write(n+ " is negative number")
</script>
</body>
</html>

Output:





Thanks For Visiting💖

Comments

Popular posts from this blog