Unity University
Department of Computer Science
Windows Programming-Assignment I
Short answer
1 declare an array of ten single precision data type (use both method )
Ans:
Dim number(8) As Single
Dim number1() As Single = {1, 2, 3, 4, 5, 6, 7, 8}
2 a) how many elements are there in the following array declaration
Dim fine (10) As short
Ans: 10 Elements
b) what is the index for the last element for the above declaration
Ans: the last index is 9
3 if you declare an array at the top of the form , you can use it throughout the form ( say true or false )
Ans: True since it is globally declared
4 a) what do you understand when an array is declared like the following
Dim kk( ) As single
Ans: The one dimensional Array is Dynamic array with Type Single
b) if we want the dimension for the above array to be changed(set)to the size of 10 . what vb.net
statement that we should write .
Ans: Dim kk(,,,,,,,,,, ) As single
C)use for loop statement and assign a value 6 to each element of array in part b above
____________________________
_____________________________
______________________________
______________________________
D) What does the following statement refer TO PART b above ? Ķ
Ubound(kk)
___________________________________________ķ
5 consider the following segment of code is written under the click event procedure of BUTTUN 1 .
Predict output in the listbox . When the button is clicked
Dim gg() AS single= { 23, 11,56,49, 34}
Array.sort(gg)
Dim i AS short
For i=0 to Ubound (kk)
LstList.item.add(gg )
Next
_________________
Programming excercise
Exercise on array to be submitted on _______________________________________
1. Write a vb.net program that find the median value for a given list of numbers
● When “enter data” button is clicked, then the program immediately request how many
Numbers are in the list. Then it stores all numbers in the list in an array using input function
● When “median “ button is clicked ,then the program display all the numbers in the list
followed by the median value as follow
Sample data for even number of element
Sample data for odd number of element
Note: median is the middle value for an array data
The program arrange the original data in ascending order , as we can see above .
Use the example format given in the example in your reference materials
2. Write a program that find the standard deviation temperature for a given number of days.
● Temperatures for the number of days are accepted using inputbox function . after accepting
the number of days for the calculation (use dynamic array to store the temperatures for the
number of days)
● Finally, an output will be displayed using textbox like we see on the example in the array
● Standard deviation for set of data is calculated
● To enter data using inputbox, then click enter temperatures button
● When display temperatures button is clicked , then the output is displayed as follow.
Sample data