'N' .AND. EOPTIGROG102 PASÖGROG133 INTRGROG133 PAS\ GROG135 INTUGROG135 PASæINTRO02BINTIINTRO02BPASÛINTRO03AINTLINTRO03APASßINTRO03BINTOINTRO03BPASâINTRO06AINT_INTRO06APAS÷INTRO06DINT[INTRO06DPASðJRT17 INTÿJRT17 PASiJRT21 INTJRT21 PASmJRT22 INTJRT22 PASoJRT23 INTJRT23 PASqJRT24A INTJRT24A PASsJRT24B INT2JRT24B PAS¼JRT25 INT JRT25 PASu JRT28 INTJRT28 PAS~JRT29 INT5JRT29 PAS¸JRT3 INTüJRT3 PASeJRT30 INTJRT30 PAS„JRT37 INT8JRT37 PASÀJRT38 INTJRT38 PASŠJRT40 INT>JRT40 PASÈJRT44 INTJRT44 PAS—JRT51 INTJRT51 PAS�JRT54 INT!JRT54 PASœ JRT68 INTCJRT68 PASÏJRT72 INT&JRT72 PAS§JRT81 INT(JRT81 PASªJRT82 INT,JRT82 PAS¯JRT98 INT/JRT98 PAS³JUG 001JPZ80 INTXPZ80 PASìÿAe@ÿ@?P@Program Tonerows; const rowlength = 12; type tonevalues = 1 .. rowlengths; row = set of tonevalues; var seed,counter,cycles : integer; tone : tonevalues; sequence : row; function randomtone (var randval : integer) : tonevalues; begin randomtone := randval mod rowlength + 1; randval := (25173 * randval + 13849) mod 65536 end; (* randomtone *) begin read (cycles,seed); for counter := 1 to cycles do begin sequence := [ ] repeat tone := randomtone (seed); if not (tone in sequence) then begin write (tone); sequence := sequence + [tone] end until sequence = [1 .. rowlength]; writeln end (* for *) end. (* tonerows *) {Program 0.1 assuming annual inflation rates of 7, 8, and 10 per cent, find the factor by which the frank, dollar, pound sterling, mark, or guilder will have been devalued in 1, 2, ... n years.} Program inflation; const n = 10; var i : integer; w1, w2, w3 : real; begin i := 0; w1 := 1.0; w2 := 1.0; w3 := 1.0; repeat i := i + 1; w1 := w1 * 1.07; w2 := w2 * 1.08; w3 := w3 * 1.10; writeln( i, w1, w2, w3 ) until i = n end.  MPZ3 ®°0300²¸P_ h$A%$A%$A%i� $Ap›% $A€›% $A›% ÿÿÿÿ ÿÿÿÿ ÿÿÿÿ ä �R2Yÿÿÿÿ«ÿÿ{Program 3.1 example of constant definition part} Program convert; const addin = 32; mulby = 1.8; low = 0; high = 39; separator = ' __________'; var degree : low..high; begin writeln( separator ); for degree := low to high do begin write( degree, 'c', round( degree * mulby + addin ), 'f' ); if odd( degree ) then writeln end; writeln; writeln( separator ) end.  MPZ17 y{0300}‡P_= __________ i äh'`a=c –$A› –™Ã=f äR^h äP#h ä= __________ i äYÿÿÿÿ$X_ÿÿ{Program 4.1 the compound statement} Program beginend; var sum : integer; begin sum := 3 + 5; writeln( sum, -sum ) end.  MPZ21 #%0300'+P_�€j äYÿÿÿÿÿÿ{Program 4.2 computer h( n ) = 1 + 1/2 + 1/3 + ... + 1/n} Program egwhile; var n : integer; h : real; begin read( n ); write( n ); h := 0; while n > 0 do begin h := h + 1/n; n := n - 1 end; writeln( h ) end.  MPZ22 WY0300[cP_iâiäh–%h”RF i––œ™%i‚P ÿÿÿÿi äYÿÿÿÿ&Dÿÿ{Program 4.3 compute h( n ) = 1 + 1/2 + 1/3 + ... + 1/n} Program egrepeat; var n : integer; h : real; begin read( n ); write( n ); h := 0; repeat h := h + 1/n; n := n - 1 until n = 0; writeln( h ) end.  MPZ23 TV0300X^P_iâiäh–% i––œ™%i‚h�R ÿÿÿÿi äYÿÿÿÿAÿÿ{Program 4.4 computer h( n ) = 1 + 1/2 + 1/3 + ... + 1/n} Program egfor; var i, n : integer; h : real; begin read( n ); write( n ); h := 0; for i := n downto 1 do h := h + 1/i; writeln( h ); end.  MPZ24A RT0300V^P_iâiä h–%iaA  i––œ™%P* ÿÿÿÿi äYÿÿÿÿ+?ÿÿ{Program 4.6 NOTE: Have patience with this one. I thought it was broke until I looked at the code carefully. It takes awhile. JRT took ten minutes,(I didn't use a stop watch) while Pascal/Z took 5 minutes. But JRT had more digit accuracy. computer 1 - 1/2 + 1/3 - ... + 1/9999 - 1/10000, 4 ways: 1) left to right, in succession 2) left to right, all pos and neg terms, then subtract 3) right to left in succession 4) right to left, all pos and neg terms, then subtract} Program summing; var s1, s2p, s2n, s3, s4p, s4n, lrp, lrn, rlp, rln : real; i : integer; begin s1 := 0; s2p := 0; s2n := 0; s3 := 0; s4p := 0; s4n := 0; for i := 1 to 5000 do begin lrp := 1/( 2 * i - 1 ); {pos terms, left to right} lrn := 1/( 2 * i ); {neg terms, left to right} rlp := 1/( 10001 - 2 * i ); {pos terms, right to left} rln := 1/( 10002 - 2 * i ); {neg terms, right to left} s1 := s1 + lrp - lrn; s2p := s2p + lrp; s2n := s2n + lrn; s3 := s3 + rlp - rln; s4p := s4p + rlp; s4n := s4n + rln; end; writeln( s1, s2p - s2n ); writeln( s3, s4p - s4n ) end.  MPZ25  0300"*P_Xh–%h–%h–%h–%&h–%.h–%Viˆ`Û6i–j–V–›i–šœ%>i–j–V–›œ%Fi–'–j–V–›šœ%Ni–'–j–V–›šœ% 6 ™> š% 6 ™% > ™% F ™N š%&& F ™%.. N ™%P4 ÿÿÿÿ  šÿÿÿÿj ä ÿÿÿÿ& . šÿÿÿÿj äYÿÿÿÿ5Ùÿÿ{Program 4.7 write roman numerals} Program roman; var x, y : integer; begin y := 1; repeat x := y; write( x, ' ' ); while x >= 1000 do begin write( 'm' ); x := x - 1000 end; if x >= 500 then begin write( 'd' ); x := x - 500 end; while x >= 100 do begin write( 'c' ); x := x - 100 end; if x >= 50 then begin write( 'l' ); x := x - 50 end; while x >= 10 do begin write( 'x' ); x := x - 10 end; if x >= 5 then begin write( 'v' ); x := x - 5 end; while x >= 1 do begin write( 'i' ); x := x - 1 end; writeln; y := 2 * y until y > 5000 end.  JRT PASCAL USERS GROUP This is the first disk full of Public Domain software from the JUG group. It is only intended as a aid for those who are just starting out in Pascal and in particular, JRT PASCAL. The JUG people are mixed in with the Pascal/Z group because of their common interest in the language of PASCAL. All of these programs run and are in SOURCE plus INT. To demonstrate that JRT can run standard Pascal I have included most of the programs out of the USER MANUAL AND REPORT written by DR.Wirth. All of the programs that have JRTxx.xxx are from that book. The only minor problems I had was the large number of reserve words JRT has, so I had to change some variable names. The other problem was SIN and EXP are externals. But those were very minor and easily found and corrected. The novice will find that these programs are simple. I could have made a comment file for each program but I wanted them to read the source to see just what the program is doing and how to interface with it. So look at the .PAS file first and understand just what is going on and then run the program. Once you known how to do that, modify the program so that there is user interaction with the program. Then it will not be necessary to read the source to see what is going on. Next, add bells and whistles to make the program fancy and useful. I want to give credit to Gerry Hewett, STAR RT., BOX 108, INYOKERN CA,93527 for his donation of most of the rest of the programs. He is learning Pascal and has taken the trouble to debug and run programs out of his text books. The same approach should be used with his programs as you do with DR.Wirth's. We want to encourage all of you beginners to write, write programs. The only way to learn a language is to look at examples and write. Once written, send them to us and we will spread them around for others to use. It is not necessary to re-invent the wheel. For my part, I will be debugging Pascal/Z programs so they can be converted to JRT. In that way, we will get some advanced examples of software in a hurry. Send donations, articles, or information to: Z/JRT PASCAL USERS 7962 Center Parkway Sacramento, Ca 95823 Thank you - Charlie Foster Program Tonerows; const rowlength = 12; type tonevalues = 1 .. rowlengths; row = set of tonevalues; var seed,counter,cycles : integer; tone : tonevalues; sequence : row; function randomtone (var randval : integer) : tonevalues; begin randomtone := randval mod rowlength + 1; randval := (25173 * randval + 13849) mod 65536 end; (* randomtone *) begin read (cycles,seed); for counter := 1 to cycles do begin sequence := [ ] repeat tone := randomtone (seed); if not (tone in sequence) then begin write (tone); sequence := sequence + [tone] end until sequence = [1 .. rowlength]; writeln end (* for *) end. (* tonerows *) {Program 0.1 assuming annual inflation rates of 7, 8, and 10 per cent, find the factor by which the frank, dollar, pound sterling, mark, or guilder will have been devalued in 1, 2, ... n years.} Program inflation; const n = 10; var i : integer; w1, w2, w3 : real; begin i := 0; w1 := 1.0; w2 := 1.0; w3 := 1.0; repeat i := i + 1; w1 := w1 * 1.07; w2 := w2 * 1.08; w3 := w3 * 1.10; writeln( i, w1, w2, w3 ) until i = n end. {Program 3.1 example of constant definition part} Program convert; const addin = 32; mulby = 1.8; low = 0; high = 39; separator = ' __________'; var degree : low..high; begin writeln( separator ); for degree := low to high do begin write( degree, 'c', round( degree * mulby + addin ), 'f' ); if odd( degree ) then writeln end; writeln; writeln( separator ) end. {Program 4.1 the compound statement} Program beginend; var sum : integer; begin sum := 3 + 5; writeln( sum, -sum ) end. {Program 4.2 computer h( n ) = 1 + 1/2 + 1/3 + ... + 1/n} Program egwhile; var n : integer; h : real; begin read( n ); write( n ); h := 0; while n > 0 do begin h := h + 1/n; n := n - 1 end; writeln( h ) end. {Program 4.3 compute h( n ) = 1 + 1/2 + 1/3 + ... + 1/n} Program egrepeat; var n : integer; h : real; begin read( n ); write( n ); h := 0; repeat h := h + 1/n; n := n - 1 until n = 0; writeln( h ) end. {Program 4.4 computer h( n ) = 1 + 1/2 + 1/3 + ... + 1/n} Program egfor; var i, n : integer; h : real; begin read( n ); write( n ); h := 0; for i := n downto 1 do h := h + 1/i; writeln( h ); end. {Program 4.6 NOTE: Have patience with this one. I thought it was broke until I looked at the code carefully. It takes awhile. JRT took ten minutes,(I didn't use a stop watch) while Pascal/Z took 5 minutes. But JRT had more digit accuracy. computer 1 - 1/2 + 1/3 - ... + 1/9999 - 1/10000, 4 ways: 1) left to right, in succession 2) left to right, all pos and neg terms, then subtract 3) right to left in succession 4) right to left, all pos and neg terms, then subtract} Program summing; var s1, s2p, s2n, s3, s4p, s4n, lrp, lrn, rlp, rln : real; i : integer; begin s1 := 0; s2p := 0; s2n := 0; s3 := 0; s4p := 0; s4n := 0; for i := 1 to 5000 do begin lrp := 1/( 2 * i - 1 ); {pos terms, left to right} lrn := 1/( 2 * i ); {neg terms, left to right} rlp := 1/( 10001 - 2 * i ); {pos terms, right to left} rln := 1/( 10002 - 2 * i ); {neg terms, right to left} s1 := s1 + lrp - lrn; s2p := s2p + lrp; s2n := s2n + lrn; s3 := s3 + rlp - rln; s4p := s4p + rlp; s4n := s4n + rln; end; writeln( s1, s2p - s2n ); writeln( s3, s4p - s4n ) end. {Program 4.7 write roman numerals} Program roman; var x, y : integer; begin y := 1; repeat x := y; write( x, ' ' ); while x >= 1000 do begin write( 'm' ); x := x - 1000 end; if x >= 500 then begin write( 'd' ); x := x - 500 end; while x >= 100 do begin write( 'c' ); x := x - 100 end; if x >= 50 then begin write( 'l' ); x := x - 50 end; while x >= 10 do begin write( 'x' ); x := x - 10 end; if x >= 5 then begin write( 'v' ); x := x - 5 end; while x >= 1 do begin write( 'i' ); x := x - 1 end; writeln; y := 2 * y until y > 5000 end. {Program 4.9 graphic representation of a function f( x ) = exp( -x ) * sin( 2 * pi * x ) } Program graph1; const d = 0.0625; {1/16, 16 lines for interval [x, x + 1]} s = 32; {32 character widths for interval [y, y + 1]} h = 34; {character position of x-axis} c = 6.28318; {2 * pi} lim = 32; var x, y : real; i, n : integer; function exp ( x : real ): real; extern; function sin ( x : real ): real; extern; begin for i := 0 to lim do begin x := d * i; y := exp( -x ) * sin( c * x ); n := round( s * y ) + h; repeat write( ' ' ); n := n - 1; until n = 0; writeln( '*' ) end end. {Program 6.2; extend program 4.9 to print x-axis} Program graph2; const d = 0.0625; {1/16, 16 lines for interval [x, x + 1]} s = 32; {32 character widths for interval [y, y + 1]} h1 = 34; {character position of x-axis} h2 = 68; {line width} c = 6.28318; {2 * pi} lim = 32; var i, j, k, n : integer; x, y : real; a : array[ 1..h2 ] of char; function exp ( x : real ): real; extern; function sin ( x : real ): real; extern; begin for j := 1 to h2 do a[ j ] := ' '; for i := 0 to lim do begin x := d * i; y := exp( -x ) * sin( c * x ); a[ h1 ] := ':'; n := round( s*y ) + h1; a[ n ] := '*'; if n < h1 then k := h1 else k := n; for j := 1 to k do write ( a[ j ] ); writeln; a[ n ] := ' ' end end. {Program 8.1 example of set operations, NOTE: free is a reserved work in JRT so I changed it to freee} PROGRAM setop; TYPE days = ( m, t, w, th, fr, sa, su ); week = SET of days; VAR wk, work, freee : week; d : days; procedure check( s : week ); {procedures introduced in Chapter 11} var d : days; begin write( ' ' ); for d := m to su do if d in s then write( 'x' ) else write ( 'o' ); writeln end; {check} begin work := []; freee := []; wk := [ m..su ]; d := sa; freee := [ d ] + freee + [ su ]; check( freee ); work := wk - freee; check( work ); if freee <= wk then write( ' o' ); if wk >= work then write( 'k' ); if not( work >= freee ) then write( ' jack' ); if [ sa ] <= work then write( 'forget it' ); writeln end. {Program 7.1 operations on complex numbers} Program complex; { * ( output ) is implicit in Pascal/Z * } const fac = 4; type complex = record re, im : integer end; var x, y : complex; n : integer; begin x.re := 2; x.im := 7; y.re := 6; y.im := 3; for n := 1 to 4 do begin writeln( 'x = ',x.re : 3, x.im : 3, ' y = ', y.re : 3, y.im : 3); {x + y} writeln( 'sum = ', x.re + y.re : 3, x.im + y.im : 3); {x * y} writeln( 'product = ', x.re * y.re - x.im * y.im : 3, x.re * y.im + x.im * y.re : 3); writeln; x.re := x.re + fac; x.im := x.im - fac; end end. {Program 8.2 generate the primes between 3..10000 using a sieve containing odd integers in this range.} Program primes; { * ( output ) is implicit in Pascal/Z * } const wdlength = 59; {implementation dependent} maxbit = 58; w = 84; {w = n div wdlength div 2} var sieve, primes : array[ 0..w ] of set of 0..maxbit; next : record word, bit : integer end; j, k, t, c : integer; empty : boolean; begin {initialize} for t := 0 to w do begin sieve[ t ] := [ 0..maxbit ]; primes[ t ]:=[] end; sieve[ 0 ] := sieve[ 0 ]-[ 0 ]; next.word := 0; next.bit := 1; empty := false; with next do repeat {find next prime} while not( bit in sieve[ word ] ) do bit := succ( bit ); primes[ word ] := primes[ word ] + [ bit ]; c := 2 * bit + 1; { * display primes--the J&W version had no * } { * output statement * } {*} writeln( c + word * wdlength * 2 ); j := bit; k := word; while k <= w do {eliminate} begin sieve[ k ] := sieve[ k ] - [ j ]; k := k + word * 2; j := j + c; while j > maxbit do begin k := k + 1; j :=j - wdlength; end end; if sieve[ word ] = [] then begin empty := true; bit := 0; end; while empty and ( word < w ) do begin word := word + 1; empty := sieve[ word ] = [] end until empty; {ends with} end. {Program 11.3 procedure parameters} Program parameters; { * ( output ) is implicit in Pascal/Z * } var a, b : integer; procedure h( x : integer; var y : integer ); begin x := x + 1; y := y + 1; writeln( x, y ) end; begin a := 0; b := 0; h( a, b ); writeln( a, b ) end. {Program 11.8 extend program 4.8} Program expon2; { * ( output ) is implicit in Pascal/Z * } var pi, spi : real; function power( x : real; y : integer ) : real; {y >= 0} var z : real; begin z := 1; while y > 0 do begin while not odd( y ) do begin y := y div 2; x := sqr( x ) end; y := y - 1; z := x * z end; power := z end; {power} begin pi := 3.14159; writeln( 2.0, 7, power( 2.0, 7 ) ); spi := power( pi, 2 ); writeln( pi, 2, spi ); writeln( spi, 2, power( spi, 2 ) ); writeln( pi, 4, power( pi, 4 ) ) end. {Program 11.9 recursive formulation of god} Program recursivegod; { * ( output ) is implicit in Pascal/Z * } var x, y, n : integer; function god( m, n : integer ) : integer; begin if n = 0 then god := m else god := god( n, m mod n ) end; {god} procedure try( a, b : integer ); begin writeln( a, b, god( a, b ) ) end; begin try( 18, 27 ); try( 312, 2142 ); try( 61, 53 ); try( 98, 868 ) end. {Program 13.1 alfa values} Program egalfa; { * The type alfa is pre-defined by: * } { * type alfa = packed array[ 1..10 ] of char; * } { * * } { *Since Pascal/Z does not have the pre-defined type * } { *alfa, and all arrays in Pascal/Z are packed implicitly, * } { *alfa must be re-defined as below * } {*}type alfa = array[ 1..10 ] of char; var n1, n2 : alfa; begin write( 'names : ' ); n1 := 'raymond '; n2 := 'debby '; if n2 < n1 then writeln( n2, n1 ) else writeln( n1, n2 ) end. {Program 4.8 exponentiation with natural exponent} Program exponentiation; var e, y : integer; u, x, z : real; begin read( x, y ); write( x, y ); z := 1; u := x; e := y; while e > 0 do begin {z * u**e=x**y, e > 0} while not odd( e ) do begin e := e div 2; u := sqr( u ); end; e := e-1; z := u * z end; writeln( z ) {z = x**y} end. {Program 4.5 compute the cosine using the expansion: cos( x ) = 1 - x**2/( 2 * 1 ) + x**4/( 4 * 3 * 2 * 1 ) - ...} Program cosine; { * ( input, output ) is implicit in Pascal/Z * } const eps = 1.0E-14; var x, sx, s, t : real; i, k, n : integer; begin for i := 1 to n do begin read( x ); t := 1; k := 0; s := 1; sx := sqr( x ); while abs( t ) > eps * abs( s ) do begin k := k + 2; t := -t * sx/( k * ( k-1 ) ); s := s + t end; writeln( x, s, k div 2 ) end end. {Program 6.1 find the largest and smallest number in a given list} Program minmax; const n = 20; var i, u, v, min, max : integer; a : array[ 1..n ] of integer; {assume that at this point in the program, array a contains the values 35 68 94 7 88 -5 -3 12 35 9 -6 3 0 -2 74 88 52 43 5 4} begin {for ease of testing, I will fill the array for you} a[1]:=35;a[2]:=68;a[3]:=94;a[4]:=7;a[5]:=88;a[6]:=-5; a[7]:=-3;a[8]:=12;a[9]:=35;a[10]:=9;a[11]:=-6;a[12]:=3; a[13]:=0;a[14]:=-2;a[15]:=74;a[16]:=88;a[17]:=52;a[18]:=43; a[19]:=5;a[20]:=4; min := a[ 1 ]; max := min; i := 2; while i < n do begin u := a[ i ]; v := a[ i + 1 ]; if u > v then begin if u > max then max := u; if v < min then min := v; end else begin if v > max then max := v; if u < min then min := u; end; i := i + 2 end; if i = n then if a[ n ] > max then max := a[ n ] else if a[ n ] < min then min := a[ n ]; writeln( max, min ) end. {Program 6.3 matrix multiplication} program matrixmul; const m = 4; p = 3; n = 2; var i : 1..m; j : 1..n; k : 1..p; s : integer; a : array[ 1..m, 1..p ] of integer; b : array[ 1..p, 1..n ] of integer; c : array[ 1..m, 1..n ] of integer; begin for i := 1 to m do { assign initial values to a and b } begin for k := 1 to p do begin read( s ); write( s ); a[ i,k ] := s; end; writeln end; writeln; for k := 1 to p do begin for j := 1 to n do begin { * read s from data file * } read( s ); write( s ); b[ k,j ] := s; end; writeln end; writeln; {multiply a * b} for i := 1 to m do begin for j := 1 to n do begin s := 0; for k := 1 to p do s := s + a[ i, k ] * b[ k, j ]; c[ i, j ] := s; write( s ) end; writeln end; writeln end. {Program 11.1 extend program 6.1} Program minmax2; const n = 20; var a : array[ 1..n ] of integer; i, j : integer; procedure minmax; var i : 1..n; u, v, min, max : integer; begin min := a[ 1 ]; max := min; i := 2; while i < n do begin u := a[ i ]; v := a[ i + 1 ]; if u > v then begin if u > max then max := u; if v < min then min := v; end else begin if v > max then max := v; if u < min then min := u; end; i := i + 2; end; if i = n then if a[ n ] > max then max := a[ n ] else if a[ n ] < min then min := a[ n ]; writeln( min, max ); writeln end; {minmax} begin for i := 1 to n do begin read( a[ i ] ); write( a[ i ] : 3 ); end; writeln; minmax; for i := 1 to n do begin read( j ); a[ i ] := a[ i ] + j; write( a[ i ] :3 ); end; writeln; minmax end. Program Hanoi; var total : integer; procedure movetower (height,fromneedle,toneedle,useneedle : integer); procedure movedisk (takeoff,puton : integer); begin writeln(takeoff:2,' > ',puton:2) end; (* movedisk *) begin if height > 0 then begin movetower(height-1,fromneedle,useneedle,toneedle); movedisk(fromneedle,toneedle); movetower(height-1,useneedle,toneedle,fromneedle) end; end; begin (* main program *) writeln('How many discs?');writeln; read (total); movetower (total,1,3,2) end. (* This is Example 2b, page 8, of Pract Intr to Pascal *) (* Calculate car running costs. *) program ex2b; const roadtax = 50.0; var garage_bill, insurance, total : real; begin writeln('Enter repair cost:'); (* Note prettyfying *) read(garage_bill); writeln('Enter insurance charge:'); read(insurance); total := garage_bill + insurance + roadtax; writeln;writeln('Total cost of operation is ',total:6) end. (* This is Example 3A, page 10, PItP: *) program ex3a; var sum,number : integer; begin writeln('Input numbers to be added: 0 ends input.'); sum := 0; (* Clear to start *) repeat read(number); sum := sum + number until number = 0; writeln('The total is: ',sum) end. (* This is Example 3B, page 11, of PItP. *) program ex3b; var a,b,product : real; power : integer; begin writeln('Input the boundary number:'); read(a); writeln('Input the number to be exponentiated:'); read(b); power := 0; product := b; while product <= a do begin power := power + 1; product := product * b end; writeln('The largest power of ',b,' < ' ,a,' is ',power) end. Program Selections; const capacity = 20; type counter = 0 .. capacity; object = 1 .. capacity; container = set of object; var numballs,samplesize : counter; Procedure select (bag : container; sample,drawn : counter); var ball : object; begin if drawn < sample then for ball := 1 to capacity do if ball in bag then begin writeln(ball : 3 * drawn); select (bag - [ball],sample,drawn + 1) end end; (* select *) begin read(numballs,samplesize); if numballs => samplesize then select ([1 .. numballs] ,samplesize,0) else writeln('Invalid data') end. (* selections *) {Program 11.7 test side effect} Program sideffect; { * (output ) is implicit in Pascal/Z * } var a, z : integer; function sneaky( x : integer ) : integer; begin z := z - x; {side effect on z} sneaky := sqr( x ); end; { * sneaky * } begin z := 10; a := sneaky( z ); writeln( a, z ); z := 10; a := sneaky( 10 ) * sneaky( z ); writeln( a, z ); z := 10; a := sneaky( z ) * sneaky( 10 ); writeln( a, z ); end. (* This is Example 6D, page 42, of PItP: the use of procedures, variable parameters, and all that good stuff. NOTE: Since 1760 * 36 is too damned big for PascalZ as implemented on my computer, the MILES conversion has been dropped. *) program ex6d; var a,b,c,d,number : integer; procedure convert (var m,y,f,i,ins : integer); begin y := ins div 36; ins := ins mod 36; f := ins div 12; i := ins mod 12 end; begin repeat writeln('Input a value (inches) to be converted:'); read (number); convert (a,b,c,d,number); writeln ('This number of inches equals'); writeln(b:4, ' Yards '); writeln(c:1, ' Feet and '); writeln(d:2, ' inches.'); until number = 0 end.(* This is Example 6A, pagec38 of PItP: procedures. *) program ex6a; var num1,num2,total : real; procedure drawaline; const line = 10; var i : integer; begin for i := 1 to line do write ('-'); writeln end; begin writeln('Input two values separated by a space:'); read(num1,num2); writeln (num1:10:3); writeln (num2:10:3); drawaline; total := num1 + num2; writeln(total:10:3); drawaline end.  MPZ3 ®°0300²¸P_ h$A%$A%$A%i� $Ap›% $A€›% $A›% ÿÿÿÿ ÿÿÿÿ ÿÿÿÿ ä �R2Yÿÿÿÿ«ÿÿ MPZ17 y{0300}‡P_= __________ i äh'`a=c –$A› –™Ã=f äR^h äP#h ä= __________ i äYÿÿÿÿ$X_ÿÿ MPZ21 #%0300'+P_�€j äYÿÿÿÿÿÿ MPZ22 WY0300[cP_iâiäh–%h”RF i––œ™%i‚P ÿÿÿÿi äYÿÿÿÿ&Dÿÿ MPZ23 TV0300X^P_iâiäh–% i––œ™%i‚h�R ÿÿÿÿi äYÿÿÿÿAÿÿ MPZ24A RT0300V^P_iâiä h–%iaA  i––œ™%P* ÿÿÿÿi äYÿÿÿÿ+?ÿÿ MPZ25  0300"*P_Xh–%h–%h–%h–%&h–%.h–%Viˆ`Û6i–j–V–›i–šœ%>i–j–V–›œ%Fi–'–j–V–›šœ%Ni–'–j–V–›šœ% 6 ™> š% 6 ™% > ™% F ™N š%&& F ™%.. N ™%P4 ÿÿÿÿ  šÿÿÿÿj ä ÿÿÿÿ& . šÿÿÿÿj äYÿÿÿÿ5Ùÿÿ MPZ28 $&0300(DP_ i=  jäè“RE=m iäè‚P"ô“Re=d iäô‚d“Rˆ=c iäd‚Pe2“R¨=l iä2‚ “RË=x iä ‚P¨“Rë=v iä‚i“R =i iäi‚Pëh äjƒˆ”R Yÿÿÿÿ+CNn†‘±ÉÔò!ÿÿ MPZ30 �µ0300·ÁP_h `Œ$?bP–›%_ ˜Z_$Abƒ ›Z›% – ›Ã"�=  iäi‚h�Rd=* i äPYEXP SIN ÿÿÿÿ~Šÿÿ MPZ38 103003QPID_biD`3 = 5Ph `$?bP–›%_ ˜Z_$Abƒ ›Z›%" =:5  – ›Ã"�  =*5 "’RÅ "PÍ  i `ñ 0 iäPØh ä  = 5P=YEXP SIN ÿÿÿÿ(1>†¨¹ÃÙãïýÿÿ MPZ51 0300-PHP_=  iäh`Cîÿ@�R7=x iäP@=o iäPh äY_8NE&NEhINE6&6N&@¼N¼E&@X@&@½E@X&@@OR¼= o iä@@MRÑ=k iä@&@M¸Rë= jack iäN@OR = forget it iäh äYÿÿÿÿ)5AŒ¤°ÆÜ÷ÿÿ MPZ44  0300"*P_j  i`=x =  = y =     ä=sum =   � � ä= product =   ƒ ƒ‚ ƒ ƒ� äh ä�‚P0Yÿÿÿÿ1ÿÿ MPZ54 µ·0300¹ëPIT_¶ ® hT`D®  h:INEV®  NEPh h @hN½E¦ h¦ i² h¦ ´ ´ ´  @�¸Rš´ ´ PqV´  V´  @´ N¼E° j´ ƒi�° ´ ;ƒjƒ�i äª ´ ¬ ´ ¬ T•R^¬  ¬  @ª N½E¬ ¬ ´ jƒ�ª ª ° �ª :”R[¬ ¬ i�ª ª ;‚P7Pò´  @NJR}² i´ h² ´ T’¹R­´ ´ i�² ´  @NJP}² RqYÿÿÿÿ(;BIP€†˜¢¬û@Y\fn‹¢«²ÿÿ MPZ72 ]_0300aiP1P_úÿúÿi�üÿüÿi�úÿüÿj äY_ hhXj äYÿÿÿÿJÿÿ MPZ81 5703009OPZP_i–%üÿh”RQüÿ¸R7üÿüÿj…ôÿôÿ )›%Püÿüÿi‚ôÿ  ›%Pìÿ %Y_$A1AY%$A ÿÿÿÿ_$A  Xÿÿÿÿ ä_ j X% ÿÿÿÿj ÿÿÿÿ ä ÿÿÿÿj_ j Xÿÿÿÿ ä ÿÿÿÿ_  Xÿÿÿÿ äYÿÿÿÿ5O”´ô$ÿÿ MPZ82 ž 0300¢ºPfP_üÿh�RøÿúÿP8øÿ_üÿúÿüÿ†XYP<_úÿüÿ_úÿüÿX äY_ X<8^X<=5X<bdX<Yÿÿÿÿ5:[t�Ž›ÿÿ MPZ98 ƒ…0300‡�PI _=names :  iä= raymond 5 = debby 5 0 0 ²Rn0  0  j äP‚0  0  j äYÿÿÿÿUlÿÿ MPZ24B ±³0300µÁP_,&i*`°iâi–%(hi–% )›% Ð$3 Л¬R‡((j�  ›(–(–i–š›œ˜%  ™%P8 ÿÿÿÿ ÿÿÿÿ(j… äPYÿÿÿÿN…®ÿÿ MPZ29 “•0300—£P_"jâ ÿÿÿÿjäi–%  %h”R‚¸Rhj…  )›%PIi‚  ›%P@ ÿÿÿÿi äYÿÿÿÿGOf€ÿÿ MPZ37 "$0300&xPI_8i #j D ^  X € €   #   €  h j€ J X 4 +   i  j’Rà  i�  ”RŽ”Rw  ’R‹  P¶ ”R¢  ’R¶ j�P,�R ”Rñ P  ’R   j äYÿÿÿÿ#0=JWes€�š¨µÀÌÙæó 5BSam�Œ˜¬ÁÌÕÞêïø ÿÿ MPZ40 ]_0300a‹P?IIIIII_Bi`Œ i`… iâ iä   PYh äPLh ä i`Øij`Ñ iâ iä&   P¥h äPšh äi`Xij`Q h i`1    &  ƒ�P2 ,  iäPñh äPæh äYÿÿÿÿMZ{ƒŠ›¦ÇÏÖçò(/=OVÿÿ MPZ68 »½0300¿P)IP_ i  j’RÆ  i�  ”R‘”Rz  ’RŽ  P¹ ”R¥  ’R¹ j�P/�R ”Rô P  ’R   j äh äY_2.i``. iâ. iäP6h ähX.i`±0iâ. . 0�. iäPsh ähXYÿÿÿÿ8EVdp„�›¯ÄÏØáíòû7AQ^gt‡‘¢¯¸ÿÿ MINTRO02Bœž0300 ¤P_=Enter repair cost: i äiâ=Enter insurance charge: i äiâ  ™$BP™%h ä=Total cost of operation is   ÿÿj äYÿÿÿÿÿÿ MINTRO03Awy0300{�P_ =(Input numbers to be added: 0 ends input. i ähiâ�h�R;=The total is:  j äYÿÿÿÿXÿÿ MINTRO03Bçé0300ëóP_ =Input the boundary number: i äiâ=%Input the number to be exponentiated: i äiâh %  ­Rši�  ›%Pt=The largest power of   ÿÿÿÿ= <   ÿÿÿÿ= is   äYÿÿÿÿ~˜ÿÿ MGROG133 ¡£0300¥µP-P_úÿüÿ †i�üÿUbüÿƒ6�h†Y_ jâi ` NE _jX @�¸R‰ iä@ N¼E@i INJRSh äPIYÿÿÿÿJ_m—žÿÿ MGROG135 {}0300‘PaP_üÿúÿ’R`i``êÿ@�R]üÿƒi äêÿ@N½úÿüÿi�XPY_ jâ�RzYÿÿÿÿ ,[^xÿÿ MPZ80 ²´0300¶ÆP!P_üÿ‚úÿüÿƒY_  _jXj ä _ jX_jXƒj ä _jX_ jXƒj äYÿÿÿÿ8^j’�ÿÿ MINTRO06D  0300 PBP_öÿüÿ$…üÿüÿ$†øÿüÿ …úÿüÿ †Y_='Input a value (inches) to be converted: i äiâ   X=This number of inches equals i ä= Yards  j ä i= Feet and  j ä j= inches. j äh�REYÿÿÿÿ‘ÿÿ MINTRO06A®°0300²ÀP'P_i `"=- iäPh äY_=&Input two values separated by a space: i äjâ  i ä  i ähX  ™%  i ähXYÿÿÿÿ ‰«ÿÿ