Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
3 views4 pages

Javascript SOP1

The document provides JavaScript code snippets for three tasks: multiplying an integer by 3, comparing two integers to find the larger one, and checking if a number is positive or negative. Each task includes HTML structure and JavaScript code that utilizes variables, prompts, and conditional statements. The code demonstrates basic programming concepts and user input handling in JavaScript.

Uploaded by

aweapon994
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)
3 views4 pages

Javascript SOP1

The document provides JavaScript code snippets for three tasks: multiplying an integer by 3, comparing two integers to find the larger one, and checking if a number is positive or negative. Each task includes HTML structure and JavaScript code that utilizes variables, prompts, and conditional statements. The code demonstrates basic programming concepts and user input handling in JavaScript.

Uploaded by

aweapon994
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/ 4

SOP 1: Create a JavaScript program for the following using

appropriate variables, JavaScript inbuilt functions, and control


structures.

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


 To accept two integers and display a larger number of them.
 To check whether the user entered number is positive or negative.
Answer:
To accept integer and display the result by multiplying it with 3.
<!DOCTYPE html>
<head>
<title>To accept integer and display the result by multiplying it with
3.</title>
</head>
<body>
<script language=”javascript”> var a,no,ans;
a=prompt(Enter any value‟);
no=parseInt(a);
ans=no*3;
document.
write(“The answer is :”+ans);
</script>
</body>
</html>
To accept two integers and display larger number of them.
<!DOCTYPE html>
<head>
<title>To accept two integers and display larger number of them.</title>
</head>
<body>
<script language=”javascript”>
var a,b;
a=prompt(„Enter first value‟);
b=prompt(„Enter second value‟);
if(a>b)
document.write(“a is large number than b “);
else
document. write(“b is large number than a”);
</script>
</body>
</html>
To check whether, user entered number is positive or negative.
<!DOCTYPE html>
<head>
<title>To check whether, user entered number is positive or
negative</title>
</head>
<body>
<script language=”javascript”>
var a,no;
a=prompt(„Enter any number‟);
no=parseInt(a);
if(no>0)
document.write(“Number is Positive”);
else
document.write(“Number is Negative”);
</script>
</body>
</html>

You might also like