Practical 1,2,3 (1) Css
Practical 1,2,3 (1) Css
Practical no 1 :
Code :
<!doctype html>
<html>
<head>
<title>Looping Statements</title>
</head>
<body>
<h1>Smit Chauhan </h1>
</body>
</html>
Output:
<!doctype html>
<html>
<head>
<title>Arithmetic Operations</title>
</head>
<body>
<h1>Addition</h1>
<script>
var a = 2, b = 5, c;
c = a + b;
document.write("1st No. = " + a + "<br>2nd No. = " + b + "<br>Addition = " + c );
</script>
<h1>Subtraction</h1>
<script>
var a = 2, b = 5, c;
c = a - b;
document.write("1st No. = " + a + "<br>2nd No. = " + b + "<br>Subtraction = " + c );
</script>
<h1>Multiplication</h1>
<script>
var a = 2, b = 5, c;
c = a * b;
document.write("1st No. = " + a + "<br>2nd No. = " + b + "<br>Multiplication = " + c );
</script>
<h1>Division</h1>
<script>
var a = 2, b = 5, c;
c = a / b;
document.write("1st No. = " + a + "<br>2nd No. = " + b + "<br>Division = " + c );
</script>
<h1>Modulus</h1>
<script>
var a = 2, b = 5, c;
c = a % b;
document.write("1st No. = " + a + "<br>2nd No. = " + b + "<br>Modulus = " + c);
</script>
</body>
</html>
Output :
Gramin Technical & Management Campus
Department of Computer Engineering
Subject/Code : CSS/22519
Name : Smit chauhan Batch : A Roll No :76
DOP : DOS :
Practical no 2 :
Code :
<!doctype html>
<html>
<head>
<title>Decision Making</title>
<style>
body {
background-color: lightblue;
}
</style>
</head>
<body>
<h1>Decision Making</h1>
<h2>Simple if Statement</h2>
<script>
var a = 2, b = 5;
if (a < b) {
document.write("1st No. = " + a + "<br>2nd No. = " + b + "<br>" + a + " is less than
" + b );
}
</script>
<h2>if-else Statement</h2>
<script>
var a = 2, b = 5;
if (a > b) {
document.write("1st No. = " + a + "<br>2nd No. = " + b + "<br>" + a + " is greater
than " + b );
} else {
document.write("1st No. = " + a + "<br>2nd No. = " + b + "<br>" + a + " is not
greater than " + b );
}
</script>
<h2>if-else if-else Statement</h2>
<script>
var a = 2, b = 5;
if (a > b) {
document.write("1st No. = " + a + "<br>2nd No. = " + b + "<br>" + a + " is greater
than " + b );
} else if (a < b) {
document.write("1st No. = " + a + "<br>2nd No. = " + b + "<br>" + a + " is less than
" + b );
} else {
document.write("1st No. = " + a + "<br>2nd No. = " + b + "<br>" + a + " is equal to "
+ b ); }
</script>
<h2>Nested if Statement</h2>
<script>
var a = 2, b = 5, c = 3;
if (a < b) {
if (a < c) {
document.write("1st No. = " + a + "<br>2nd No. = " + b + "<br>3rd No. = " + c +
"<br>" + a + " is less than both " + b + " and " + c );
} else {
document.write("1st No. = " + a + "<br>2nd No. = " + b + "<br>3rd No. = " + c +
"<br>" + a + " is less than " + b + " but not less than " + c);
}
} </script>
</body>
</html>
Output :
Code :
<!doctype html>
<html>
<head>
<title>Looping Statements</title>
<style>
body {
background-color: lightblue;
}
</style>
</head>
<body>
<h1>Looping Statements</h1>
<h2>For Loop</h2>
<script>
document.write("<strong>Numbers from 1 to 5:</strong><br>");
for (var i = 1; i <= 5; i++) {
document.write(i + "<br>");
}
</script>
<h2>While Loop</h2>
<script>
document.write("<strong>Numbers from 6 to 10:</strong><br>");
var i = 6;
while (i <= 10) {
document.write(i + "<br>");
i++;
}
</script>
<h2>Do-While Loop</h2>
<script>
document.write("<strong>Numbers from 11 to 15:</strong><br>");
var i = 11;
do {
document.write(i + "<br>");
i++;
} while (i <= 15);
</script>
<h2>For in Loop</h2>
<script>
var person = {name: "Smit", age: 18};
for (var p in person) {
document.write( person[p] + "<br>");
}
</script>
</body>
</html>
Output :
Gramin Technical & Management Campus
Department of Computer Engineering
Subject/Code : CSS/22519
Name : Smit chauhan Batch : A Roll No :76
DOP : DOS :
Practical no 3:
Code :
<html>
<body>
<script>
var i;
var emp = new Array();
emp[0] = "Arun";
emp[1] = "Varun";
emp[2] = "John";
for (i=0;i<emp.length;i++){
document.write(emp[i] + "<br>");
}
</script>
</body>
</html>
Output:
Code:
<html>
<body>
<script>
var emp=["Ashwatthama","krishna","Smit"];
for (i=0;i<emp.length;i++){
document.write(emp[i] + "<br/>");
}
</script>
</body>
</html>
Output: