0% found this document useful (0 votes)
7 views10 pages

Pra 2 Css

The document contains practical examples of conditional statements and looping statements in JavaScript. It includes code snippets for if statements, if-else statements, nested if statements, switch case statements, and various types of loops such as for, while, and do-while loops. Each code snippet is followed by an expected output description.

Uploaded by

Sumedh Raut
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views10 pages

Pra 2 Css

The document contains practical examples of conditional statements and looping statements in JavaScript. It includes code snippets for if statements, if-else statements, nested if statements, switch case statements, and various types of loops such as for, while, and do-while loops. Each code snippet is followed by an expected output description.

Uploaded by

Sumedh Raut
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 10

NAME:- SUMEDH SANJAY RAUT

CLASS:- CO5I(A)

ROLL NO:-532

SUBJECT:- CSS(22519)

PRACTICAL NO:- 2

 Conditional Satement :-
1- If Satatement
Code:-
<html>

<head>

<title>if statment</title>

<script type="text/javascript">

var age=16;

if(age>=18)

document.write("Licence can be issued.");

if(age<18)

document.write("Licence can not be issued.");

</script>

</head>

<html>
Output:-

2- If -else Statement

Code:-
<html>

<head>

<title> If else Statement </title>

<body></body>

<script>

var age=19;

if(age>=18)

document.write("Licence can be issued");

else

document.write("Licence can not be issued");

</script>

</head>

</html>
Output:-

3) I f …ElseIf Statement

Code:-
<html>

<head>

<title>if statment</title>

<script type="text/javascript">

var one=30;

var two=20;

if(one==two)

document.write(one+" is equal to "+two);

else if(one<two)

document.write(one+" is less than "+two);

else

document.write(one+" is Greater than "+two);

}
</script>

</head>

<html>

Output:-

4) Nested If Statement

Code:-
<html>

<head>

<title>if statment</title>

<script type="text/javascript">

var one=30;

var two=20;

if(one==two)

document.write(one+" is equal to "+two);

else if(one<two)

document.write(one+" is less than "+two);

else
{

document.write(one+" is Greater than "+two);

</script>

</head>

<html>

Output:-

Switch Case Statement

Code:
<html>

<head>

<title>Switch case statment</title>

<script>

var i=3;

switch(i)

case 0:

document.write("i is zero"); break;

case 1:

document.write("i is one"); break;

case 2:
document.write("i is two");

break;

default:

document.write("i is Greater than two");

</script>

</head>

</html>

Output:-

*Looping Statement

1)For Loop

Code:-
<html>

<head>

<title> For Loop</title>

<h3>***for Loop***</h3><br>

<body>

<script>

var i;

for(i=0;i<=10;i++)
{

document.write("The number is: "+i+"<br>");

</script>

</head>

</body>

</html>

Output:-

2)While Loop

Code:-
<html>

<head>

<title> For Loop</title>

<body>

<script>

var i;

for(i=0;i<=10;i++)

document.write("The number is"+i+"<br>");

}
</script>

</head>
</body>

</html>

Output:-

3) Do While Loop

Code:-
<html>

<head>

<h3>***Do While Loop***</h3>

<body>

<script>

var i=1;

do {

document.write("The number is"+i+"<br>");

i++;

}while(i<=5)

</script>

</head>

</body>

</html>
Output:-

4) For While Loop

Code:-
</html>

<html>

<title> Looping Statement</title>

<h3>***For..in Loop***</h3>

<script>

const string="Sumedh";

for(let i in string)

document.write(string+"<br>");

</script>

</html>
Output:-

You might also like