Understanding Two-dimensional Array in VB.NET: Lab Exercise - Prof. Nancy Mccracken, Lab Reports of Information Technology

Instructions for a lab exercise in vb.net focused on understanding a two-dimensional array. Students are required to write an expression to access a specific element, analyze a code snippet that calculates the sum of array elements, and determine the output of the code during the first iteration.

Typology: Lab Reports

Pre 2010

Uploaded on 08/09/2009

koofers-user-yfn
koofers-user-yfn 🇺🇸

10 documents

1 / 1

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
IST 256
Lab Week 14 – November 24, 2008
(only one part this week)
1. Understanding a Two-dimensional Array Program
Suppose that we have a two-dimensional array that was read in from the file
“samples.txt”, as shown in class. Shown here is the declaration of the array and how it
would look:
Dim numbers(0 To 5, 0 To 2) As Integer
numbers Column 0 Column 1 Column 2
Row 0 15 3 -7
Row 1 25 6 99
Row 2 35 -20 17
Row 3 45 10 3
Row 4 55 22 4
Row 5 65 -9 11
a. Write an expression that will give the array element in Row 2, Column 1:
What is the value of this element?
b. Here is a code fragment that shows a nested loop that iterates over every element of
the array.
Dim total as Integer
Label1.Text = “ “
For row = 0 to 5
total = 0
For col = 0 to 2
total = total + numbers(row,col)
Next
Label1.Text = Label1.Text & “Sum over “ & row &”= “ & total & vbCrLf
Next
Given the values in the numbers array, what will the value of Label1.Text be during the
first iteration of the outermost loop, when row = 0?
What are the remaining values given in the Label?

Partial preview of the text

Download Understanding Two-dimensional Array in VB.NET: Lab Exercise - Prof. Nancy Mccracken and more Lab Reports Information Technology in PDF only on Docsity!

IST 256

Lab Week 14 – November 24, 2008

(only one part this week)

1. Understanding a Two-dimensional Array Program

Suppose that we have a two-dimensional array that was read in from the file “samples.txt”, as shown in class. Shown here is the declaration of the array and how it would look:

Dim numbers(0 To 5, 0 To 2) As Integer numbers Column 0 Column 1 Column 2 Row 0 15 3 - Row 1 25 6 99 Row 2 35 -20 17 Row 3 45 10 3 Row 4 55 22 4 Row 5 65 -9 11

a. Write an expression that will give the array element in Row 2, Column 1:

What is the value of this element?

b. Here is a code fragment that shows a nested loop that iterates over every element of the array. Dim total as Integer Label1.Text = “ “ For row = 0 to 5 total = 0 For col = 0 to 2 total = total + numbers(row,col) Next Label1.Text = Label1.Text & “Sum over “ & row &”= “ & total & vbCrLf Next

Given the values in the numbers array, what will the value of Label1.Text be during the first iteration of the outermost loop, when row = 0?

What are the remaining values given in the Label?