Assignment of chapter - 6
What will be the output of following?
Function replicate(ch as string)
Dim pmstr as string
For I=1 to 10
Pmstr=pmstr & ch
Next I
Replicate = pmstr
End function
Str=replicate(“*”)
Print str
Sub t()
Dim anum,bnum,k as integer
Anum=24567
K=1
bnum=0
Do while k<=5
Bnum=bnum*10
K=anum mod 10
Loop
Print k,anum,bnum
Sub one()
Dim A as integer
A=10
Print A
Call two(A)
Print A
End sub
Sub two(B as integer)
B=15
Print B
End sub
Sub one()
Dim A as integer
A=10
Print A
Call two(A)
Print A
End sub
Sub two(ByVal B as integer)
B=15
Print B
End sub
Dim st as string
Dim k as integer
st=”INDIAN”
do while k<=len(st)
print left(st,k)
k=k+1
loop
Private function sqlarge(a as integer, bas integer)
If a> b then
sqlarge=a
else
sqlarge=b
endif
end function
A=sqlarge(10,15)
Print A
Sub one(optional a as integer=10)
Print a
End sub
Call one
Call one(3)
Sub one(a as integer, optional b as integer=20)
Print a+b
End sub
Call one(3)
Call one(4,5)
Complete the following
A function takes integer argument and returns double of that integer
Sub function do(_______________)
Dim b as integer
B=_____________
Print b
Do=____________
End function
A procedure takes integer argument and change it double of that integer
Sub do(_______________)
Dim b as integer
B=_____________
Print b
____________
End sub
A function which accept two data whose value can be changed and returns a integer
_________________________________
A function which accept two data whose value can’t be changed and returns a Boolean
____________________________________
Q1. Write a function sum (), which takes integer as parameter, and return sum of all the digits of the number.
Q2. Write a function power (), which takes two parameter x an integer and p as integer and return x to the power of p, and if p is not passed take p as 2(default value of p is 2).
Q3. What are the types of modules in VB? Explain with suitable example.
Q4. Differentiate between ordinary local variable and static local variable?
Q5. What are functions in VB?
Q6 What do you mean by the scope of a variable?
Q7. What is the difference between the following codeof swap1 and swap2
Sub Swap1(byval A as integer, byval B as integer)
Dim T as integer
T=A
A=b
B=T
End sub
Sub Swap1(byref A as integer, byref B as integer)
Dim T as integer
T=A
A=b
B=T
End sub
Sum command1_click()
Dim A,B as integer
A=inputbox(“enter data 1”)
B=inputbox(“enter data2”)
Swap1(A,B)
Print A,B
A=inputbox(“enter data 1”)
B=inputbox(“enter data2”)
Swap2(A,B)
Print A,B
End
Input in both case is A=1,B=2
Q6. What do you mean by lifetime of a variable?
Q7. What will be the output of following code:
Sub r()
Static a as integer
A=10
A=A+10
Print A
End sub
Sun cmd1_click()
For I=1 to 10
R()
Next I
End
No comments:
Post a Comment