Program to convert an array of test grades (0-100) into "letter grades" (0-4). program grades; type a300 = array[1..300] of integer; var grade: a300; used: integer; match, command: string; procedure figure(var score: a300; var limit:integer); var i: integer; begin i := 0; while i < limit do begin i := i + 1; if y[i] >= 90 then begin y[i] := 4; end else begin if y[i] >= 80 then begin y[i] := 3; end else begin if y[i] >= 70 then begin y[i] := 2; end else begin if y[i] >= 60 then begin y[i] := 1; end else begin y[i] := 0; end; end; end; end; end; end; begin {code to load data into grade and set used to tell how many values were entered.} figure(grade, used); {code to make use of the grades in grade} end. Note: In class we used a more compact form of the nested if/then/else statements by omitting the begin/ends where there was only one statement in the compand statement and by using a different indentation scheme. This format is often used for deeply nested if/then/else structures like this. (The alternative is to keep indenting until you run off the right side of the page :-) The more compact form is shown below but is logically identical. if y[i] >= 90 then y[i] := 4 else if y[i] >= 80 then y[i] := 3 else if y[i] >= 70 then y[i] := 2 else if y[i] >= 60 then y[i] := 1 else y[i] := 0; Program with factorial procedure that uses recursion to calculate the factorial: program recurse; var i, j: integer; procedure fact(var n, f: integer); var m, g: integer; begin writeln(' fact in: ', n); {debugging output} if n <= 1 then begin f := 1; end else begin m := n - 1; fact(m, g); f := n * g; end; writeln(' fact out: ', f); {debugging output} end; begin write('n? '); readln(i); fact(i, j); writeln(i:5, ' factorial is ',j:6); readln; end. Note that the statements flagged with {debugging output} would normally not be included but are here to give some clues as to how it all works. Sample output: >n? <4 > fact in: 4 > fact in: 3 > fact in: 2 > fact in: 1 > fact out: 1 > fact out: 2 > fact out: 6 >fact out: 24 > 4 factorial is 24