0% found this document useful (0 votes)
12 views5 pages

Javascript Practical

The document contains multiple JavaScript programs demonstrating basic operations such as printing 'Hello World', performing arithmetic operations (addition, subtraction, multiplication), calculating simple interest, and converting between Celsius and Fahrenheit. It also includes examples of using conditional statements to find the largest number among given values and a form for adding two numbers. Each program is presented in HTML format with corresponding outputs.

Uploaded by

niloo Ram Poyam
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)
12 views5 pages

Javascript Practical

The document contains multiple JavaScript programs demonstrating basic operations such as printing 'Hello World', performing arithmetic operations (addition, subtraction, multiplication), calculating simple interest, and converting between Celsius and Fahrenheit. It also includes examples of using conditional statements to find the largest number among given values and a form for adding two numbers. Each program is presented in HTML format with corresponding outputs.

Uploaded by

niloo Ram Poyam
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

Object :- Write a program to print Hello Word in Javascript

<html>
<body>
<h1>My Web Page</h1>
<p id="demo"></p>
<script>
[Link]("demo").innerHTML = "<h2>Hello World</h2>";
</script>
</body>
</html>

Output-

My Web Page
Hello World

Object :- Write a program Addition of Two Number in javascript


<html>
<head>
<title> Addition of Two Number</title>
</head>
<body>
<script>
var a,b,c;
a=10;
b=20;
c=a+b;
[Link](c);
</script>
</body>
</html>

Output:
30

Object :- Write a program Subtraction of Two Number in javascript


<html>
<head>
<title> Addition of Two Number</title>
</head>
<body>
<script>
var a,b,c;
a=10;
b=20;
c=a-b;
[Link](c);
</script>
</body>
</html>

Output:
-10
Object :- Write a program Multification of Two Number in javascript
<html>
<head>
<title> Addition of Two Number</title>
</head>
<body>
<script>
var a,b,c;
a=10;
b=20;
c=a*b;
[Link](c);
</script>
</body>
</html>

Output:
200
Object : Write a program to simple interest in javascript
<html>
<body>
<h2>JavaScript in Simple Interest</h2>
<script>
var P,R,T,SI;
P = 10000;
R = 5;
T = 3;
SI = ((P*R*T)/100);
[Link](SI);
</script>
</body>
</html>

Output:-

1500
Object : Write a program to Area of Circle in javascript
<html>
<body>
<h2>JavaScript in Area of Circle</h2>
<script>
var r,pi,a;
r = parseInt(prompt("enter the radius"));
pi=3.14;
a=pi*r*r;
[Link](a);
</script>
</body>
</html>
Output:-

153.86
Object : Write a program if statement in javascript
<html>
<body>
<h2>JavaScript in if statement </h2>
<script>
var a=33;
if(a>32)
{
[Link](“You Are Passed”);
}
</script>
</body>
</html>
Output:-
You Are Passed
Object : Write a program to find largest number (if_else statement ) in javascript
<html>
<body>
<h2>JavaScript in if statement </h2>
<script>
var a=20,b=50;
if(a>b)
alert("A is greater then b");
else
alert("B is greater then a");
</script>
</body>
</html>
Output:-
B is greater then a
Object : Write a program to find largest among three number (if_else statement ) in javascript
<html>
<body>
<h2>JavaScript in if statement </h2>
<script>
var a,b,c;
a=10;
b=20;
c=30;
if(a>b)
if(a>c)
alert(a);
else
alert(c);
if(b>c)
alert(b);
else
alert(c);
</script>
</body>
</html>
Output:-
30

Object : Write a program to find Celsius to Fahrenheit Converter in javascript


<html>
<head>
<title>Celsius-Fahrenheit Converter</TITLE>
</head>
<BODY>
<TABLE border=3 width="40">
<TR><TD>Celsius</TD><TD>Fahrenheit
</TD></TR>
<SCRIPT language="javascript">
var i = prompt("");
{
[Link]("<TR><TD>"+i+"</TD><TD>"
+((i*9/5)+32)+"</TD></TR>");
}
</script>
</table>
</body>
</html>
Output:-
enter the value 5
41
Object : Write a program to find Fahrenheit to CelsiusConverter in javascript
html>
<head>
<title>Celsius-Fahrenheit Converter</TITLE>
</head>
<BODY>
<TABLE border=3 width="20">
<TR><TD>Fahrenheit</TD><TD>Celsius
</TD></TR>
<SCRIPT language="javascript">
var F = prompt("");
{
[Link]("<TR><TD>"+F+"</TD><TD>"
+((F-32)*5/9)+"</TD></TR>");
}
</script>
</table>
</body>
</html>
enter the value 5
-15
Object : Write a program to Form for addition of numbers in javascript

<html>
<head>
<title>
Add two numbers
</title>
<style>
body {
background-color: #BBFFFF;
color: red;
}
</style>
</head>
<body>
<form name="add" action="#" method="POST">
<center>
<marquee><h1>Form for addition of numbers</h1></marquee>
<table>
<tr><td>Enter x</td><td>:</td>
<td><input type="text" name="x"></td>
</tr>
<tr><td>Enter y</td><td>:</td>
<td><input type="text" name="y"></td>
</tr>
<tr><td colspan="3"><center><input type="button" value="Add"
onClick="[Link]=Number([Link])+Number([Link])">
</center></td></tr>
<tr><td>Result</td><td>:</td><td>
<input type="text" name="res"readonly></td>
</tr>
</table>
</center>
</form>
</body>
</html>

You might also like