CSS - Exp 2 - PDF - UPDATED MONDAY
CSS - Exp 2 - PDF - UPDATED MONDAY
CODE:
<html>
<head>
<title> Exp2.1 </title>
<script>
var a=parseInt(prompt("Enter 1st No: "));
var b=parseInt(prompt("Enter 2nd No: "));
var c=parseInt(prompt("Enter 3rd No: "));
if((a>b)&&(a>c))
alert("Largest is: "+a);
else if((b>c)&&(b>a))
alert("Largest is: "+b);
else
alert("Largest is: "+c);
</script>
</head>
</html>
OUTPUT:
▪ Write a program to check whether the entered character s a vowel or not
CODE:
<html>
<head>
<title> Exp2.2 </title>
<script>
var x=prompt("Enter a character:");
switch(x)
{
case 'a':
case 'A':
case 'e':
case 'E':
case 'i':
case 'I':
case 'o':
case 'O':
case 'u':
case 'U':
document.write("Entered character is a vowel");
break;
default:
document.write("Entered character is not a
vowel");
break;
}
document.write("<br>");
document.write("220402-Ansari Abdullah");
</script>
</head>
</html>
OUTPUT:
▪ Write a program to print odd number between 1 to 20 using while loop
CODE:
<html>
<head>
<title> Exp2.3 </title>
<script>
var i=1;
while(i<=20){
if(i%2!=0)
{
document.write(i+" ");
}
i++;
}
document.write("<br>");
document.write("210403-Midhat Ansari");
</script>
</head>
</html>
OUTPUT:
▪ Write a menu driven program for addition & subtraction until the user wanted
to continue using do while loop
CODE:
<html>
<head>
<title> Exp2.4 </title>
<script>
do{
var a=parseInt(prompt("Enter no. 1"));
var b=parseInt(prompt("Enter no. 2"));
var ch=parseInt(prompt("Enter your choice: 1)Addition
2)Subtraction"));
var x;
switch(ch)
{
case 1:
alert("Addition= "+(a+b));
break;
case 2:
alert("Subtraction= "+(a-b));
break;
default:
alert("Invalid choice!!");
break;
}
x=prompt("Do you want to continue further? Enter
Y/N");
}while(x=='Y');
</script>
</head>
<body>
</body>
</html>
OUTPUT:
▪ Write a program to print the right-angled triangle
CODE:
<html>
<head>
<title> Exp2.5 </title>
<script>
var i;
var r=parseInt(prompt("Enter total number of
rows:"));
//document.write(r);
for(i=1;i<=r;i++)
{
for(j=1;j<=i;j++)
{
document.write("* ");
}
document.write("<br>");
}
document.write("<hr>");
document.write("210403-Midhat Ansari");
</script>
</head>
</html>
OUTPUT: