Practical 2

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 7

Practical 2

<html>
<head>
<title>ARMSTRONG NO</title>
</head>
<body>
<h1> ARMSTRONG NUMBERS FROM 1 TO 1000 </h1>

<script>
document.write("Armstrong numbers from 1 to 1000:");
for(var i=1; i<=1000; i++)
{
var n = i;
var count=0, mod, sum=0;
while(n>0)
{
mod =n%10;
sum = sum+(mod *mod* mod);
n = parseInt(n/10);
}
if(sum==i)
{
document.write(i+"<br>");
}
}
</script>
</body>
</html>

<!DOCTYPE html>
<html>
<head>
<title>Calculator</title>
<h1>Calculator Program Using Switch Case</h1>
</head>
<body>
<script>
const operator = prompt('Enter Operator (+,-,*,/)');
const number1 = parseFloat(prompt('Enter first number:'));
const number2 = parseFloat(prompt('Enter second number:'));
switch(operator)
{
case '+':
result = number1 + number2;
document.write(`${number1} + ${number2} = ${result}`);
break;
case '-':
result = number1 - number2;
document.write(`${number1} - ${number2} = ${result}`);
break;
case '*':
result = number1 * number2;
document.write(`${number1} * ${number2} = ${result}`);
break;

case '/':
result = number1 / number2;
document.write(`${number1} / ${number2} = ${result}`);
break;
}
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<title>Even No</title>
<h1> Even No Using DO While Loop</h1>
</head>
<body>
<script>
var i=1;
do
{
if(i%2==0)
{
document.write(i+" ");
}
i++;
}while(i<=20);
</script>
</body>
</html>

<!DOCTYPE html>
<html>
<head>
<title>Fibonacci Series</title>
<h1>Fibonacci series</h1>
</head>
<body>
<script>
var i=0;
var j=1;
var k;
while(i<=100)
{
document.write(i+"<br>");
k=i+j;
i=j;
j=k;
}
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<title>For In Loop</title>
<h1>For In Loop</h1>
</head>
<body>
<script>
var person;
person={Name:"Siddhi",Surname:"Gawade",Age:19};
var x;
for(x in person)
{
document.write("<b>"+x+"</b>"+" = " + person[x]+"<br>");
}
</script>
</body>
</html>

<!DOCTYPE html>
<html>
<head>
<title>PRACTICAL 2</title>
<h1>Largest Of 3 Numbers</h1>
</head>
<body>
<script>
var a=10 , b=20 , c=30;
if((a>b)&&(a>c))
{
document.write("A is Largest No");
}
else if((b>a)&&(b>c))
{
document.write("B is Largest No");
}
else
{
document.write("C is Largest No");
}
</script>
</body>
</html>
<?php
Write a program to display pyramids of star/patterns using increment/decrement

$rows=5;
for($i=0;$i<$rows;$i++)
{
for($j=0;$j<$rows-$i-1;$j++)
{
echo "&nbsp;&nbsp;";
}
for($star=0;$star < 2 * $i + 1;$star++)
{
echo "*";
}
echo "<br>";
}
?>

Output :

You might also like