**Advanced Pascal Programming Language Problems**

**© 1998 by Dr. Thomas W. MacFarland -- All Rights Reserved**

Instructions: Review the following program and see if you can predict the outcome by completing a "pencil trace" of the code. Program output is provided at the end of this page. Compiler: The program was prepared using Standard Pascal on a UNIX-based host computer.

```
% cat PASCAL/advanced_pencil-13.p
{ Advanced Pascal Programming Language Exercises
Dr. Thomas W. MacFarland
advanced_pencil-13.p
}
{ The purpose of this program is to:
1. Demonstrate the use of an array of integer variables.
2. Demonstrate how elements of an array can be used in
a math activity.
3. Demonstrate the construction of a multiplication table.
}
program Demonstrate_Arrays_4;
var Result : array[1..4,1..5] of integer;
R : integer;
C : integer;
begin
for R := 1 to 4 do
for C := 1 to 5 do
Result[R, C] := R * C;
for R := 1 to 4 do begin
for C := 1 to 5 do
write(' ', R:1, '*', C:1, ' = ', Result[R,C]:3);
writeln;
end;
end. {advanced_pencil-13.p}
% pc PASCAL/advanced_pencil-13.p
% a.out
1*1 = 1 1*2 = 2 1*3 = 3 1*4 = 4 1*5 = 5
2*1 = 2 2*2 = 4 2*3 = 6 2*4 = 8 2*5 = 10
3*1 = 3 3*2 = 6 3*3 = 9 3*4 = 12 3*5 = 15
4*1 = 4 4*2 = 8 4*3 = 12 4*4 = 16 4*5 = 20
```