CS1001 - D Term, 2000
Laboratory 6 - Two-Dimensional Arrays
Date: April 26, 2000
The trace of a square matrix is defined as the sum of the elements on
the main diagonal from the
upper lefthand corner to the lower righthand corner. For example, the
trace of the matrix below is
10+(-2) + 4, or 12.
10 5
7
5 -2 -1
0 9
4
Here is what you need to do:
On a separate piece of paper, write your name, wpi login
name, and section number. Answer
the following question: assuming that every integer is
stored in two memory words, how many
words of memory would be needed to hold the array defined
by the following declaration:
INTEGER,DIMENSION(3,2,5) :: Table
Hand your paper in to the TA.
Write a program that will
1. read in the size of a square matrix of integers that
is less than or equal to 10 x 10
2. Read in the elements of this matrix
3. Calculate the trace
4. Output the value of the trace
Compile your program.
(continued on reverse side)
Create a typescript file showing a sample run of your program. Here is a sample execution:
>f90 lab6.f90
>a.out
Enter the size of a square matrix (less than or
equal to 10):
3
Enter the elements of the matrix
Enter elements for row
1:
10
5
7
Enter elements for row
2:
5
-2
-1
Enter elements for row
3:
0
9
4
The trace of your matrix is:
12
>
Turn in your program and typescript file electronically by typing in the command
/cs/bin/turnin submit lab6 lab6.f90 lab6.script
This document was generated using the LaTeX2HTML translator Version
97.1 (release) (July 13th,
1997)
Copyright © 1993, 1994, 1995, 1996, 1997, Nikos Drakos, Computer
Based Learning Unit,
University of Leeds.
The command line arguments were:
latex2html lab6.tex.
The translation was initiated by Nitin John on 4/13/2000