CPS 1 (Ramm) Spring 1995 15 February 1995 Quiz #5 Name _______________________ Section _____ A. Below is the first part of a Pascal program. Assume that it reads in the numbers shown to the right of the program. Show the contents of array t by writing the numbers in the box below representing t in memory. program ara; | DATA type | 2.0 t10 = array[1..10] of real; | -2.0 var | 4.0 t: t10; | -4.0 i, j, n: integer; | 6.0 extreme, heating, cooling, total: real; | -6.0 begin | 8.0 n := 10; | -8.0 i := 0; | 10.0 while i < n do | -10.0 begin | writeln('Enter T:'); | i := i + 1; readln(t[i]); end; 1 2 3 4 5 6 7 8 9 10 ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- t | | | | | | | | | | | ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- B. Assume that the program continues with following codes. What is the output? extreme := t[1]; total := t[1]; i := 1; while i < n do begin i := i + 1; if t[i] < extreme then begin extreme := t[i]; end; total := total + t[i]; end; writeln('extreme = ', extreme:5:1, ' sum = ', total:5:1); C. The program finishes with the following code. What output is produced. i := 0; cooling := 0.0; while i < n do begin i := i + 1; if t[i] > 0.0 then begin cooling := cooling + t[i]; end; end; writeln('cooling load = ', cooling:5:1); readln; end.