Saturday, 21 December 2013

JAVASCRIPT FOR DISPLAY NUMBERS FROM 1 TO 10
USING FOR LOOP.
 INPUT:
        <html>
<head><h1> Display numbers from 1 to 10 using <strong><i>for loop</i></strong></h1></head>
<body>
                <H1>
<script>
var i;
for(i=1;i<=10;i++)
document.write(i,"<br>");
</script>
</h1>
</body>
</html>

JAVASCRIPT FOR ADDING TWO NO.
INPUT:
<html>
<head><h1>Addition Of Two Numbers</h1></head>
<body>
<H1>
<script>
var a=5;
var b=15;
c=a+b;
document.write("a =",a,"<br>b =",b,"<br>c =",c);
</script>
</h1>
</body>
</html>

JAVASCRIPT FOR DISPLAY NUMBERS FROM 1 TO 10
USING WHILE LOOP.
INPUT: 
<html>
<head><h1> Display numbers from 1 to 10 using <strong><i>while loop</i></strong></h1></head>
<body>
<H1>
<script>
var i=1;
while(i<=10)
{
document.write(i,"<br>");
i++;
}
</script>
</h1>
</body>
</html>

  

JAVASCRIPT FOR DISPLAY NUMBERS FROM 1 TO 10
USING DO-WHILE LOOP.
   INPUT:
<html>
<head><h1> Display numbers from 1 to 10 using <strong><i>Do-while loop</i></strong></h1></head>
<body>
<H1>
<script>
var i=1;
do
{
document.write(i,"<br>");
i++;
}
while(i<=10)
</script>
</h1>
</body>
</html>

JAVASCRIPT FOR DISPLAY NUMBERS FROM 1 TO 10
USING CONTINUE.
   INPUT:
<html>
<head><h1> Display numbers from 1 to 10 using <strong><i>Continue</i></strong> statement.</h1></head>
<body>
<H1>
<script>
var i;
for(i=1;i<=10;i++)
{
if(i==5)
{
continue;
}
document.write(i,"<br>");
}
</script>
</h1>
</body>
                </html>

JAVASCRIPT FOR DISPLAY EVEN NUMBERS BETWEEN    1 TO 100
   INPUT:
<html>
<head><h1> Display even numbers between 1 to 100.</h1></head>
<body>
<H1>
<script>
var i;
for(i=1;i<=100;i++)
{
if(i%2==0)
{
document.write(i,"<br>");
}
}
</script>
</h1>
</body>
</html>


JAVASCRIPT FOR FACTORIAL.
   INPUT:
<html>
<body>
<H1>
<script>
var i,n=5,f=1;
for(i=1;i<=5;i++)
f=f*i;
document.write("factorial of 5 = ",f);
</script>
</h1>
</body>
</html>


JAVASCRIPT FOR FIBONACCI SERIES.
   INPUT:
<html>
<head><h1>Fibonacci series.</h1></head>
<body>
<H1>
<script>
var i,a=0,b=1,c,t,n=10;
document.write(a,"<br>");
document.write(b,"<br>");
for(i=2;i<=9;i++)
{
c=a+b;
a=b;
b=c;
document.write(c,"<br>");
}
</script>
</h1>
</body>
</html>

JAVASCRIPT FOR  PRIME OR NOT.
 INPUT:
<html>
<head><h1> Check whether the numbers are prime or not .</h1></head>
<body>
<H1>
<script language="javascript">
var c,i,x;
for(x=2;x<=100;x++)
{
c=0;
for(i=2;i<=(x/2);i++)
{
if((x%i)==0)
c++;
}
if(c==0)
{
document.write(x," is a prime number<br>");
}
else
{
document.write(x," is not a prime number<br>");
}
}
</script>
</h1>
</body>
</html>
JAVASCRIPT FOR TABLE OF 5 .
 INPUT:
<html>
<head><h1> Table of 5 till 20. </h1></head>
<script>
var a=1,b=5,c;
for(a=1;a<=20;a++)
{
c=b*a;
document.write("<b>5*",a,"=",c,"<br></b>");
}
</script>
</head>
</html>

JAVASCRIPT FOR ARRAY.
INPUT:
<html>
<body>
<script>
<strong>
var fy= new Array();
fy[0]="aaa";
fy[1]="bbb";
fy[2]="ccc";

fy.sort();
document.write(fy[0]+fy[1]+fy[2]);
</script>
</strong>
</body>
</html>

JAVASCRIPT FOR DATE.
INPUT:
<html>
<body>
<b>
HH:MM:SS =
<script type="text/javascript">
var ct = new Date()
var hour = ct.getHours()
var minute = ct.getMinutes()
var sec = ct.getSeconds()
document.write(hour + ":" + minute + ":" + sec)
</script>
</b>
</body>
</html>
JAVASCRIPT FOR MATH FUNCTION. ROLL NO:212018
INPUT:
<html>
<body>
<b>
<script type="text/javascript">
document.write("Cosine value of 90 = "+Math.cos(90))
document.write("<br>Max of 10,20 = "+Math.max(10,20))
document.write("<br>Power of 2 raise to 5 = "+Math.pow(2,5))
document.write("<br>Exponential value of 90 = "+Math.exp(90))
document.write("<br>Log of 1 = "+Math.log(1))
document.write("<br>Minimum of 54,65,24 = "+Math.min(54,65,24))
document.write("<br>Rounded value of 25.645 = "+Math.round(25.645))
document.write("<br>Tan value of 45 = "+Math.tan(45))
document.write("<br>Square root of 64 = "+Math.sqrt(64))
</script>
</b>
</body>
</html>