CSC 301 – Visual Programming

CSC 301 – Visual Programming
Class Quiz – 2 Group2
Student Name:
Time: 10 minutes
Date: Tuesday, 11/06/1436
Total Marks: 10
Answer all questions
Question 1 (4 Marks)
1) Write a statements that allows you to create an integer array of 6 elements
with the following values: {55,70,90,40,0,0}. Then computes the number of
elements which have a value greater than 59 and stores it at element 4, then
store the maximum number at element 5.
………………………………………………………………………………………
……………………………………………………………………………………….
………………………………………………………………………………………
……………………………………………………………………………………….
………………………………………………………………………………………
……………………………………………………………………………………….
………………………………………………………………………………………
……………………………………………………………………………………….
………………………………………………………………………………………
……………………………………………………………………………………….
2) Write a method header Smallest, which takes three integers, x, y and z, and
returns an integer.
………………………………………………………………………………………
……………………………………………………………………………………….
3) What is the output of the following code fragment:
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs)
Handles MyBase.Load
Dim x As Integer = 5
Modify(x)
MsgBox(x)
End Sub
Sub Modify(ByVal y As Integer)
y=y*2
End Sub
………………………………………………………………………………………
……………………………………………………………………………………….
1
Question 2 (6 Marks)
Write statements to do the following:
a. Create an array of size 3 and assign the values ("Wala", "Mona", "Noha") to it.
………………………………………………………………………………………
……………………………………………………………………………………….
b. Sort the previous array in part A in ascending order and display the sorted values
in message box.
………………………………………………………………………………………
……………………………………………………………………………………….
………………………………………………………………………………………
………………………………………………………………………………………
………………………………………………………………………………………
………………………………………………………………………………………
c. Show the values of the previous array (in part B) in a combo box as below
………………………………………………………………………………………
……………………………………………………………………………………….
………………………………………………………………………………………
d) write a function called LasIndex which accepts an array of integer and an
integer value to search about. The function returns the last index of the value if the
value is found or it returns -1 if the value is not found.
………………………………………………………………………………………
………………………………………………………………………………………
………………………………………………………………………………………
………………………………………………………………………………………
………………………………………………………………………………………
………………………………………………………………………………………
………………………………………………………………………………………
………………………………………………………………………………………
………………………………………………………………………………………
………………………………………………………………………………………
………………………………………………………………………………………
Good Luck
2