You are on page 1of 6

Programming with Visual Basic (02073223)

1st/2nd/Final Exam – Feb 17, 2021

ID: 201911775
Name: Hussein abutayeh

Section: ___________________________________________

Instructions:
 Turn off your mobile phone
 Time: 9:00 – 11:00
 Enquiries are only allowed during the first (15) minutes of exam time
 Use the space provided. In case you need more spaces, you could use the back
of the page.
 Answer all questions: Mandatory ( 2), Optional ( ), Bonus ( )

Total Number of Questions ( 2 )


Number of Pages ( 5 )

Best of Luck
AZMI EL-
ESSA

Page 1 of 6
AAO-P10-R01 3 30/9/2018
FACULTY OF ADMINISTRATIVE & FINANCIAL SCIENCES
DEPARTMENT OF M.I.S

SECTION 1: MANDATORY/ OPTIONAL / BONUS (6 POINTS)


Question-1) Answer each of the following (in writing) with True or False. (1/2 Point each)

Seq Answer
Definition
1) All variables must be declared with a name and a data type before they can T
be used in a program.
2) The != operator compares two numbers to determine if they are not equal. F
3) Arrays consist of items of different types. F
4) The value used to indicate a specific location within an array is called the F
index or subscript.
5) The following line of code is valid. T
If 90 ≤ grade ≤ 100 Then
6) A Function may return up to two values. F
7) You can display the Properties window by pressing F5. F
8) The Text property of a combo box gives the currently highlighted item. F
9) An assignment statement assigns a variable to a value. F
10) A PictureBox is Visual Basic’s control that enables you to display an image. F
11) A declaration may declare only one variable at a time. F
12) Only one CheckBox in a group can be selected at a time. T

AAO-P10-R01 3 30/9/2018
Programming with Visual Basic (02073223) 2/6
FACULTY OF ADMINISTRATIVE & FINANCIAL SCIENCES
DEPARTMENT OF M.I.S

SECTION 2- ANSWER EACH OF THE FOLLOWING : (34 POINTS)

What will be the output of the following commands (programs)


Seq
Question Answer

1 How many times will Final Exam be printed when the following lines (2 points)

are executed?
Dim c As Integer = 5 19
Do
Print " Final Exam "
c += 5
Loop Until (c >= 20)
2 What is the output produced by the following segment (2 points)
last = -2
i=0 Will not print
Do While i <= last anything in
Print i; output
i=i+1
Loop
3 What is the output after executing the following program? (2 points)
Private Sub Command1_Click()
Dim x As String, y As String VB VB
x = "VB"
y = "Final"
Call exam(x, y)
Print x; " "; y
End Sub
Sub exam(x As String, y As String)
Dim temp As String
temp = x
x=y
y = temp
End Sub
4 What is the output of the following program? (2 points)
Private Sub cmdButton_Click()
Dim x As Single, y As Single, z As Single, result As Single 16
Cls
x = 2.0
y = 3.0
z = 3.0
result = Int(Norm(x, y, z))
Print result
End Sub
Private Function Norm(x As Single, y As Single, z As Single) As Single
Norm = Sqr(x^2 + y^2 + z^1)
End Function
5 How many times will AAUP be displayed when the following (2 points)

lines are executed? 1713


For c = 1 to 17 Step 6
Print "AAUP"
Next c

AAO-P10-R01 3 30/9/2018
Programming with Visual Basic (02073223) 3/6
FACULTY OF ADMINISTRATIVE & FINANCIAL SCIENCES
DEPARTMENT OF M.I.S
6 (2 points)
What is the output of the following?
Private Sub cmdButton_Click() 0
Dim x As Single, y As Single, z As Single
x=3
y=3
If x > y Then
z=x+y
Else
z=y-x
End If
Print z
End Sub
7 Consider the array: (2 points )
s( 0 ) = 7 9
s( 1 ) = 0
s( 2 ) = -12
s( 3 ) = 9
s( 4 ) = 10
s( 5 ) = 3
s( 6 ) = 6
Print s( s( 3 ) – s( 6 ) )

8 Given that x = 7, y = 2, and z = 4 (2 points )


What the following If block will print ? false

If (x > y) AND (y > z) Then


Print "TRUE"
else
Print "False"
End If
9 What is the output of the following program? (3 points )
Private Sub Command1_Click()
Dim num As Integer 9
num = 10 80
Call DM(num)
num = 5
Call DM(num)
num = 2
Call DM(num)
End Sub

Private Sub DM(num As Integer)


If num <= 3 Then
Print 3 * num;
Else
If num > 8 Then
Print 8 * num;
End If
End If
End Sub

AAO-P10-R01 3 30/9/2018
Programming with Visual Basic (02073223) 4/6
FACULTY OF ADMINISTRATIVE & FINANCIAL SCIENCES
DEPARTMENT OF M.I.S
10 (4 points )
What values are placed in the array by the following statements? (Show
Element Value
each element of the array and the value for that element.)
======= ====
Dim nums (1 To 5) As Single
Dim index As Integer
nums(1 ) =5
For index = 5 To 1 step -1 nums(2 ) =8
nums(index) = 2 + index * 3 nums(3 ) =11
Next index nums(4 ) =14
nums(5 ) =17

11 Assume the array num() has been filled as shown (4 points )


NUM() 1 2 3
1 3 1 2 3
2 6 4 5 4
3 7 9 8 8
What is the output of the following program segment?
For j = 1 To 3
For m = 1 To 2
If num(j, m) > num(j, m + 1) Then
temp = num(j, m)
num(j, m) = num(j, m + 1)
num(j, m + 1) = temp
End If
Next m
Next j
Print num(1,1)
Print num(2,2)
Print num(3,3)
12 What will be the output after each of the following commands is (3 points )

executed?(1/2 point Each)


Print Mid$("VB Final Exam ", 1,3) Feb
Print Left$("Feb 17 2021", 3) Z
Print chr(90) 66
Print Asc("B") 3
Print 15 Mod 4 True
Print “Chase” < “Chaz

13 Rewrite the following If…Then segment using Select Case. (4 points)


If…Then Select Case
If A = 5 Then Dim category As String
Category = "FYO"
Dim A As Integer
ElseIf A >= 13 and A <= 19 Then
Category = "Te"
ElseIf (A >= 20 and A <= 35) Or A = 50 Or (A >= 60 and A <= 65) Then Select case category
Category = "SA" case "Fyo"
ElseIf A > 65 Then
if A = 5
Category = "SC"
Else case A>=13 and A = 19
Category = "Everyone" case "5A"
End If if (A>=20 and A<=35) or
A=50 or (A>60 and A<=65)
case else
category = "Everyone"
End Select

AAO-P10-R01 3 30/9/2018
Programming with Visual Basic (02073223) 5/6
FACULTY OF ADMINISTRATIVE & FINANCIAL SCIENCES
DEPARTMENT OF M.I.S
End of Questions …… Good Luck

AAO-P10-R01 3 30/9/2018
Programming with Visual Basic (02073223) 6/6

You might also like