CIVIL 3010 array examples
CIVIL 3010 array examples
Examples
1. Using one or more arrays, write a Visual Basic program to read in a 10 x 10 matrix from
cells(1,1) to cells(10,10) and then print out the matrix below it starting with cells(12,1).
2. Write a Visual Basic program to read in two 2 x 3 matrices [A] and [B], add them together,
and output the resulting matrix [C]=[A]+[B]. After execution, your spreadsheet should look
like:
48
3. Write a Visual Basic program to read in any m x n matrix [A] starting in cells(5,1) and then
output the transpose matrix [A]T below [A]. For example, for a 3 x 4 [A] matrix, after
execution your spreadsheet should look like:
For example, for a 8 x 2 [A] matrix, after execution your spreadsheet should look like:
49
The part of the code for reading in a generic m x n matrix, calculating m and n, and then re-
dimensioning the [A] and [A]T arrays is
50
4. Write a Visual Basic program to read in a 3 x 3 matrix [A] and a 3 x 2 matrix [B], multiply
them together, and then output the resulting matrix [C] = [A] x [B]. After execution, your
spreadsheet should look like:
The part of the code for calculating each entry of the resulting [C] matrix is:
For k = 1 To 3
Next k
51