chapter 15 questions
TRANSCRIPT
![Page 1: Chapter 15 Questions](https://reader038.vdocument.in/reader038/viewer/2022100802/577ccf281a28ab9e788f0560/html5/thumbnails/1.jpg)
Q12. <html>
<script language="VBScript">
Sub Rep(x, y)
For a=1 to x
Document.Write(y)
Document.Write("<BR>")
next
End Sub
Rep 7,"name" Calling the subroutine and passing the arguments
</script>
</html>
Q13.
<html>
<script language="VBScript">
Sub leap(x)
z=x MOD 4
If z=0 Then
Document.Write("It’s a leap year")
Else
Document.Write("Not a leap year")
End If
End Sub
leap 2001 Calling the subroutine and passing the arguments
</script>
</html>
Q14
<html>
<script language="VBScript">
Sub tri(x,y,z)
If x< y+z and y< x+z and z<x+y Then
Document.Write("It’s a triangle")
Else
Document.Write("Not a triangle")
End If
End Sub
tri 6,7,16 Calling the subroutine and passing the arguments
</script>
</html>
Q15
<html>
<script language="VBScript">
Sub GetLargest(x,y,z)
If x> y and x> z Then
Document.Write(x & " is the largest")
Else
If y> x and y> z Then
Document.Write(y & "is the largest")
Else
Document.Write(z & " is the largest")
End If
End If
End Sub
GetLargest 6,7,16 Calling the subroutine and passing the arguments
</script>
</html>
Q16
<html>
<script language="VBScript">
Dim result
result=1
Function getexponent(x, y)
For a=1 to x
result=result *y
next
getexponent= result Function returns value
End Function
z=getexponent(3, 2) Calling Function and storing value in a new
variable
Document.Write("2 raised to power 3 is "& z) Output is
with the new variable
</script>
</html>
Q17
<html>
<script language="VBScript">
sub pattern(x)
max=Len(x)
for a=1 to max
document.write(Left(x,a))
document.write("<br>")
next
End Sub
pattern "HELLO" Calling the subroutine and passing the argument
</script>
</html>
Output: H
HE
HEL
HELL
HELLO
These are from out of the book
<html>
<script language="VBScript">
Sub pattern(x)
max=Len(x)
for a=1 to max
document.write(strreverse(Left(x,a))) Same as above just reversed
document.write("<br>")
next
End Sub
pattern "HELLO"
</script>
</html>
Output: H
EH
LEH
LLEH
OLLEH
Function to convert Fahrenheit to Celsius
<html>
<script language="VBScript">
Function converttocelsius(F)
converttocelsius=(F-32)*5/9
End Function
Temp=InputBox("Enter Temperature in Farhenhiet")
Cel=converttocelsius(Temp)
Document.Write("Temperature in Celsius is "&Cel)
</script>
</html>
![Page 2: Chapter 15 Questions](https://reader038.vdocument.in/reader038/viewer/2022100802/577ccf281a28ab9e788f0560/html5/thumbnails/2.jpg)
<html>
<head>
<script language ="vbscript">
Sub B1_OnClick
F1.T2.Value=Month(CDate(F1.T1.Value))
F1.T3.Value=Year(CDate(F1.T1.Value))
End Sub
</script>
</head>
<body>
<Form Name="F1">
<P>Enter your Date of Birth: <Input type="text" Name="T1" >
<P>You were born in :<Input type="text" Name="T2" > Month
<P>You were born in :<Input type="text" Name="T3" > Year
<P> <Input Type="Button" Value="Submit" Name="B1">
</Form>
</body>
</Html>
In this above code I have a form named F1 and a subroutine B1_OnClick to handle the form when user inputs
Date of Birth in Textbox T1 and clicks the “Submit” button. The Button will automatically trigger the
Subroutine B1_OnClick.
The subroutine will convert the value stored in Textbox T1 of form F1 into date using CDate inbuilt function
then in textbox T2 it will store Month using the inbuilt function and in textbox T3 it will store Year using the
inbuilt function.