0% found this document useful (0 votes)
5 views

web programming Lab manual

The document contains a series of exercises demonstrating various programming concepts including data types, arithmetic operations, decision-making statements, loops, regular expressions, arrays, file handling, subroutines, functions, strings, tuples, exception handling, iterators, hashes, and file I/O in different programming languages like JavaScript, VBScript, and Ruby. Each exercise includes coding examples and outputs to illustrate the concepts. The document is structured with headings for each exercise, but lacks specific aims and algorithms.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

web programming Lab manual

The document contains a series of exercises demonstrating various programming concepts including data types, arithmetic operations, decision-making statements, loops, regular expressions, arrays, file handling, subroutines, functions, strings, tuples, exception handling, iterators, hashes, and file I/O in different programming languages like JavaScript, VBScript, and Ruby. Each exercise includes coding examples and outputs to illustrate the concepts. The document is structured with headings for each exercise, but lacks specific aims and algorithms.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 29

Ex.

No: 1
Date : DATATYPES, VARIABLE & DIALOG BOXES

Aim :

Algorithm :

Page | 1
Coding
<html>
<head>
<title>Arithmetic operators in Javascript</title></head>
<body>
<script type="text/javascript">
var a=parseInt(prompt("enter first number"));
var b=parseInt(prompt("enter second number"));
var sum;
var difference;
var product;
var quotient;
sum=a+b;
difference=a-b;
product=a*b;
Quotient=a/b;
document.write("Sum= ");
document.write(sum);
document.write("<br>");
document.write("Difference =");
document.write(difference);
document.write("<br>");
document.write("Product=");
document.write(product);
document.write("<br>");
document.write("Quotient=");
document.write(quotient);
Page | 2
</script>
</body>
</html>

Output

Page | 3
Ex.No: 2
Date : DECISION MAKING & LOOP STATEMENT

Aim :

Algorithm :

Page | 4
Coding
Decision making statement
<html>
<body>
<h1>if statement</h1>
<h2>Vote Status</h2>
<p id="test"></p>
<script>
let age = 20
if (age > 18) {
document.getElementById("test").innerHTML = "The Candidate is Eligible to
Vote";
}
</script>
</body>
</html>

Page | 5
Loop statement
<html>
<body>
<h1>The While Loop</h1>
<h2>Displaying Marks</h2>
<p id="test"></p>
<script>
let marks = "";
let i = 95;
while (i < 100) {
marks += "<br>Marks = " + i;
i++;
}
document.getElementById("test").innerHTML = marks;
</script>
</body>
</html>>

Page | 6
Ex.No: 3
Date : REGULAR EXPRESSION

Aim :

Algorithm :

Page | 7
regular expression
<html>
<body>
<h2>JavaScript Regular Expressions</h2>
<p>Search for an "e" in the next paragraph:</p>
<p id="p01">The best things in life are free!</p>
<p id="demo"></p>
<script>
let text = document.getElementById("p01").innerHTML;
const pattern = /e/;
document.getElementById("demo").innerHTML = pattern.test(text);
</script>
</body>
</html>

Output

Page | 8
Ex.No: 4
Date : ARRAY

Aim :

Algorithm :

Page | 9
VB SCRIPT - ARRAY
<html>
<body>
<script language = "vbscript" type = "text/vbscript">
Dim arr(5)
arr(0) = "1" 'Number as String
arr(1) = "VBScript" 'String
arr(2) = 100 'Number
arr(3) = 2.45 'Decimal Number
arr(4) = #10/07/2013# 'Date
arr(5) = #12.45 PM# 'Time

document.write("Value stored in Array index 0 : " & arr(0) & "<br />")
document.write("Value stored in Array index 1 : " & arr(1) & "<br />")
document.write("Value stored in Array index 2 : " & arr(2) & "<br />")
document.write("Value stored in Array index 3 : " & arr(3) & "<br />")
document.write("Value stored in Array index 4 : " & arr(4) & "<br />")
document.write("Value stored in Array index 5 : " & arr(5) & "<br />")

</script>
</body>
</html>

Page | 10
OUTPUT

Page | 11
Ex.No: 5
Date : FILES AND FOLDERS

Aim :

Algorithm :

Page | 12
FILES
<html>
<body>
<%
dim fs, f
set fs=Server.CreateObject("Scripting.FileSystemObject")
set f=fs.GetFile(Server.MapPath("testread.txt"))
Response.Write("The file testread.txt was created on: " & f.DateCreated)
set f=nothing
set fs=nothing
%>
</body>
</html>

OUTPUT

Page | 13
FOLDER
<html>
<body>
<%
Dim fs,fo
Set fs=Server.CreateObject("Scripting.FileSystemObject")
Set fo=fs.GetFolder("c:\test")
Response.Write("Folder created: " & fo.DateCreated)
set fo=nothing
set fs=nothing
%>
</body>
</html>

OUTPUT

Page | 14
Ex.No: 6
Date : SUBROUTINES AND FUNCTIONS

Aim :

Algorithm :

Page | 15
SUBROUTINES
<html>
<head>
<script type="text/vbscript">
sub mySub()
msgbox("This is a sub procedure")
end sub
</script>
</head>
<body>
<script type="text/vbscript">
call mySub()
</script>
<p>A sub procedure does not return a result.</p>
</body>
</html>
OUTPUT

Page | 16
FUNCTION
<html>
<head>
<script type="text/vbscript">
function myFunction()
myFunction = "BLUE"
end function
</script>
</head>
<body>
<script type="text/vbscript">
document.write("My favorite color is " & myFunction())
</script>
<p>A function procedure CAN return a result.</p>
</body>
</html>

OUTPUT

Page | 17
Ex.No: 7
Date : STRINGS AND TUPLES

Aim :

Algorithm :

Page | 18
STRINGS
print("Hello")
print('Hello')

TUPLES
thistuple = ("apple", "banana", "cherry", "apple", "cherry")
print(thistuple)

output

Page | 19
Ex.No: 8
Date : RANGE & LIST

Aim :

Algorithm :

Page | 20
RANGE
x = range(6)
for n in x:
print(n)

OUTPUT

LIST
thislist = ["apple", "banana", "cherry", "apple", "cherry"]
print(thislist)
output

Page | 21
Ex.No: 9
Date : EXCEPTION HANDLING

Aim :

Algorithm :

Page | 22
EXCEPTION HANDLING
try:
print(x)
except NameError:
print("Variable x is not defined")
except:
print("Something else went wrong")

OUTPUT

Page | 23
Ex.No: 10
Date : ITERATORS

Aim :

Algorithm :

Page | 24
ITERATORS IN USING RUBY
#!/usr/bin/ruby
ary = [1,2,3,4,5]
ary.each do |i|
puts i
end

Output

Page | 25
Ex.No: 11
Date : HASHES

Aim :

Algorithm :

Page | 26
HASHES
#!/usr/bin/ruby
months = Hash.new( "month" )
puts "#{months[0]}"
puts "#{months[72]}"

Page | 27
Ex.No: 12
Date : FILES AND IO

Aim :

Algorithm :

Page | 28
FILES AND IO

#!/usr/bin/ruby
val1 = "This is variable one"
val2 = "This is variable two"
puts val1
puts val2

#!/usr/bin/ruby
puts "Enter a value :"
val = gets
puts val

Page | 29

You might also like