{ CS 1621 Strings in standard Pascal. Note how primitive and restrictive these seem } program pstrings(input,output); const maxS = 20; type String = packed array[1..maxS] of char; { String type declared above. Packed array allows readln and writeln to work on variable as a whole } procedure backward(S: String; size: integer); var i: integer; begin for i := size downto 1 do begin write(S[i]); end; writeln; end; var S1, S2: String; { Now S1 and S2 must be declared at the same time and of the same physical size. Thus, we need to keep length variables for both } i, size1, size2: integer; begin { main } for i := 1 to maxS do begin S1[i] := ' '; S2[i] := ' '; end; size1 := 10; write('Enter ', size1:1, ' characters: '); readln(S1); write('How long is your name? (up to ', maxS:1, ' chars): '); readln(size2); write('Enter your name: '); readln(S2); write(S1:size1, ' backward is '); backward(S1, size1); write(S2:size2, ' backward is '); backward(S2, size2); end.