APPENDIX I THE PASCAL RESERVED WORDS AND REQUIRED IDENTIFIERS
The following are the Pascal reserved words. Each has a special meaning and may not be redefined: AND ARRAY BEGIN CASE CONST DIV DO DOWNTO ELSE END FILE FOR FUNCTION GOTO IF IN LABEL MOD NIL NOT OF OR PACKED PROCEDURE PROGRAM RECORD REPEAT SET THEN TO TYPE UNTIL VAR WHILE WITH The following are the 'required identifiers' of the Pascallanguage. It is possible, but inadvisible, to redefine them du ring a program. INTEGER REAL CHAR BOOLEAN ABS ARCTAN CHR COS DISPOSE EOF EOLN EXP FALSE GET INPUT LN MAXINT NEW ODD ORD OUTPUT PACK PAGE PRED PUT READ READLN RESET REWRITE ROUND SIN SQR SQRT SUCC TEXT TRUE TRUNC UNPACK WRITE WRITELN The following word is a required directive and has also been assigned a special meaning in the language: FORWARD Some implementations have additional predefined functions and procedures. APPENDIX 11 SYNTAX DIAGRAMS
Pascal syntax should follow the route indicated in the following diagrams. In these diagrams the following rules hold: (a) 'Letter' means any one of the 26 letters of the English alphabet.1t may be in either upper case or lower case. The Pascallanguage does not differentiate between upper case and lower case letters except within character strings. (b) 'Digit' means any one of the decimal digits 0 .. 9. (c) 'Character' me ans any one letter or digit or other symbol. In theory this means any of the printable characters in a character set such as ASCII (see Appendix IV) but in practice there are often implementation limitations. (d) All other tokens appearing within circles or boxes with semicircular ends should be reproduced in the program exactly as they appear in the diagram, except that letters may be in upper or lower case. (e) All items in solid rectangular boxes are defined in this appendix.
program 241
block
~---r--~ unsigned integer ~--__ '- ./
identifier (constant identifier) 242
statement
expression 1------1
function identifier
procedure identifier
)------..1 unsigned integer 1------' 243
parameter I ist
,------, '----~I conformant array parameter specification !-,___ ....J ~------~see note 3
expression
'--....lo..__ .lo.... __.l!..... __.lo.... __.lo.... __.l..j~simple expression 244
simple expression
term
factor - ...... ------+-1 unsigned constant I------,...... ,~
function identifier 245 type
t }------~ type identifier 1-----1
simple type 246
field list
variable -~-+-l variable identifier I------...,..-'~
field identifier
array identifier
record identifier field identifier
pointer identifier I------...,..-'-~ t
file identifier 247
constant identifier
unsigned number
unsigned number
u nsigned integer l+-----+l~ unsigned integer
unsigned integer
Note 1 The semi-colon before the END of a CASE statement was not permitted in so me earlier Pascal implementations. Note 2 The requirement for a parameter list in procedural and func tional parameters was introduced in BS 6192 : 1982. It may not be per mitted in some earlier implementations. Note 3 Conformant array parameters are a feature of Level 1 of BS 6192: 1982. They are not discussed in this book which claims to comply only with Level 0 of the Standard. APPENDIX 111 INTERACTIVE INPUT
In Chapter 8 it was briefly mentioned that there are two main ways of implementing INPUT when a keyboard is used. One is direct and the other is via a line buffer. This appendix considers the two methods in more detail and the implications they have when programming for interactive operation.
III.1 mE UNE BUFFER MEmOD
The line buffer method requires that the < newline > key must be pressed after the called-for data has been entered. Figure III.1 shows diagram matically what is happening immediately before the < newline > key is pressed. The line buffer is acting as though it were in write mode with the keyboard supplying the data.
Fig III.1 the fine buffer method of interactive input before the
Now is the time for all good men Une buffer
Figure III.2 shows the position immediately after pressing the < newline > key. The line buffer is now in read mode and the Pascal pro gram's buffer variable is positioned to read the data. 249
Fig I1I.2 the line buffer method of interactive inputs after the
I Keyboard I EOLN
Une buffer
Pascal program being executed
To see how this works in practice, let us look at a simple program:
EBQ§BB~ CharHandling (INPUT, OUTPUT);
character : CHAR;
I!~§H! B~E~B! WRITE ('Input a character )'; READ (character); WRITELN ('Character is )', character); WRITELN ~~!lb character = 'X' ~~!?
The result of running this program using the line buffer method is
Input a character >II-f Character is )A
Input a character >B-f Character is >8
Input a character >X-f Character is >X
Note that each character input has been followed by the pressing of the < newline > key. The line buffer can introduce one feature that may be undesirable. Let us run the program again, but this time we shall supply more data than is needed to satisfy the first read list: 250
Input. a charact.er >RBX~ Charact.er is jA
Input. a charact.er >Charact.er is >B
Input. a charact.er >Charact.er is >X
On the second iteration there were still two characters, Band X, in the buffer. The READ statement accepted the B without waiting for a new character to be keyed in. Similarly, on the next iteration X was accepted. The judicious use of READLN will avert the problem of unwanted data left in the buffer, but see the remarks on the use of READLN for inter active working at the end of Chapter 8. An essential feature of any interactive working is that there should be a method of correcting errors made by mis-keying. The usual way to do this is by use of a < backspace > or similar key. The great advantage of the line buffer method is that such errors can usually be corrected before the
III.2 THE DIRECT METHOn
The direct method of interactive data entry is exemplified diagrammatically in Fig. 111.3. Each character value is passed straight from the keyboard to the buffer variable. If we run the above CharHandling pro gram with this method we would get the following:
Input. a charact.er >RCharact.er is >A
Input. a charact.er )BCharact.er is >B
Input. a charact.er >XCharact.er is >X
This layout differs from that obtained with the line buffer method because we have not had to press the < newline > key after entering each character. For games and similar programs the ability of the direct method to 251
Fig 111.3 the direct method of interactive input: each character is passed straight from the keyboard to the Pascal program; the pro grammer must write his or her own procedure for dealing with ,backspaced' corrections
Pascal program being executed respond to the single entry of any key can be a distinct advantage. Also there is no line buffer to hold unwanted characters. The main disadvantage of this method is that for certain applications the Pascal programmer may need to provide his own procedure for the correction of keying errors. APPENDIX IV ASUBSET OF THE ACSII CODE
The American Standard Code for Information Interchange is used to define the ORD values of characters in many Pascal implementations. The table on the next page lists those characters that are likely to be used generally by Pascal programmers, together with their values. 253
Ord Chr Ord Chr Ord Chr 32 < space > 64 (aJ 33 ! 65 A 97 a 34 " 66 B 98 b 35 #or f: 67 C 99 c 36 $ 68 D 100 d 37 % 69 E 101 e 38 & 70 F 102 f 39 ' (quote) 71 G 103 g 40 ( 72 H 104 h 41 ) 73 105 42 * 74 J 106 j 43 + 75 K 107 k 44 , (comma) 76 L 108 45 77 M 109 m 46 . (fuH stop) 78 N 110 n 47 / 79 0 111 0 48 0 80 P 112 P 49 1 81 Q 113 q 50 2 82 R 114 51 3 83 S 115 s 52 4 84 T 116 53 5 85 U 117 u 54 6 86 V 118 v 55 7 87 W 119 w 56 8 88 X 120 x 57 9 89 Y 121 Y 58 90 Z 122 z 59 91 [ 123 { 60 < 61 = 93 ] 125 } 62 > 94 t 63 ?
In addition to the above there are several control characters that, when output to some printers, have special significance. Among these are 8 Back-space 9 Horizontal tabulate 10 Line feed 12 Form feed (to the top of next page) 13 Carriage return REFERENCES
BS 6192: 1982 (1982). Computer programming language Pascal, British Standards Institution, London Huggins, E. (1979). Microprocessors and Microcomputers: Their Use and Programming, Macmillan, London and Basingstoke Jensen, K. and Wirth, N. (1975). Pascal User Manual and Report, Springer Verlag, New York Ledgard, H. F., Hueras, J. F. and Nagin, P. A. (1979). Pascal with Style, Hayden Book Co., Rochelle Park, NJ. Moroney, M. J. (1951). Facts from Figures, Penguin Books, Harmonds worth, Middlesex Vincent, G. and Gill, J. (1981). Software Development, 2nd edn, Texas Instruments, Bedford Wirth, N., see Jensen ANSWERS 10 EXERCISES
CHAPTER2
2.1 100 25 4 4 4 100. Intermediate steps are j4 = -11 ,j3 = -4,j2 = 1oo,j3 = 4, j4=4,r4= 100,r3=4andr2=25.
2.2
eßQ§8e~ ConvertInches (INPUT~ OUTPUT);
~aB VAR miles~ yards, feet. 1nches~ length INTEGER:
!l~§!!'! WRITE("Length ? ~); READ (length); inches := length MOn 12; length := length DIV lZ; feet := length MOD 3; length := length DIV 3; yards := length MOD 1760; miles := length DIV 1760; WRITE('Mlles =", miles, ~yards yards) ; WRITELN("feet =".feet. "inches inches); ~!,!Q.
CHAPTER3
3.1 and 3.2 These exercises are discussed in Chapter 4. 3.3 (a) By reducing the value of timeConst. (b) By nesting the FOR loop inside another thus
EQI3 m := 1 !Q 1000 RQ [OB n := 1 1Q tlmeConst QQ etc. 256
(c) By making timeConst a yariable of type INTEGER, instead of a constant and by READing its value at the start of the program.
CHAPTER4
4.1
E8Q§Bß~ MultiplicationTables (OUTPUT);
\!BB k~ m, n INTEGER,
~!;§ll:'! EQB k := CI !Q 2 QQ ~!;§m EQB m:= IQ 12 QQ ~!;§m EQB n := ~ +
4.2
~!':§!I:'! total : == 0; WRITELN ('Number Hours Wagerate Week" "s pay"); WRITELN, WRITE e?'):; READ (num):; ~t!!~~ num <> I) QQ ~!;§!I:'! READ (hours, wageRate); weeksPay := hours * wageRate; WRITELN (weeksPay :38 :2); total := total + weeksPay; WRITE ('7'); READ (num) ~~J2; WRITELN ('------' :38), ~RITELN ('Total wages for week :f:" :29, total :9 :2); WRITELN ('======' :38) !;I:'!Q.
total := 0; WRITELN ( 'Number Hours Wagerate WRITELN, WRITE ('?'), READ (num); B!;E!':BI READ (hours, wageRate); weeksPay := hours * wageRate; WRITELN (weeksPay :38 :2); total := total + weeksPay; WRITE C?'); READ (num) Y~I!b num = 0 ; WRITELN (' ------, : 38) , WRITELN (~Total wages for week f:." :29, total :9 :2); WRITELN ('======' :38) !;I:'!Q. 257
!l!;;!W'! total : = 0; WRITELN ('Number Hours Wagerate Week~>s pay'); WRITELN; B!;;E!;;f!I WRITE e?'); READ (num); !E num <> 0 I~~~ !l!;;§!M READ (hours, wageRate); wee~sPay := hours * wageRate; WRITELN (weeksPay :38 :2); total := total + weeksPay !;;M!1 UNTIL num = 0 ; WRITELN ('------' :38); WRITELN (~Total wages for week f:' :29, total :9 :2); WRITELN ('======' :38) !;;M!1· 4.3
B!;;E!;;f!I EQ8 n := 1 IQ 7 !1Q !l!;§!M seed := seed • 2; seed := seed ~~ prime ~~Q; !E seed <= 9999 I~M ete
CHAPTER6
6.1
EBQ§Bf!!:1 L,,,rc:ise61 ;
~~~ eh : CHAR; !l!;;§!M B!;;E!;;f!! READ (eh); WRITELN (eh 2~ ORD (eh) 4) !JMIR eh = !;;M!1·
6.2
!l!;;§!M REAO (eh), !E (eh >='(1') f!1'!1l (eh <='9') It!!;1'! WRITE ('digit') !;;!o§!; !E (eh >='A') f!Mll (eh <='1') !t!!;1'! "tc
6.3
WRITE ('You win "). IE (number ~QQ 3 = 0) B~Q E~§~ WRITELN (·nothlng. Bad luc~~") 258 CHAPTER8 8.1 ~Bg§Be~ CleanData (OUTPUT, MarksFi!e, Cleanfile); !;Q!:l§! lineLength ~ 100; numForms -= 6; l1BB eh : CHAR; lineCount : INTEGER; spac:e : BOOLEAN; MarksFile, CleanFile TEXT; !!~!HM RESET (HarksFile); REWRITE (CleanFile); space := FALSE; lineCount := 0; WHILE NOT EOF (HarksFile) ~Q ~§!~ --- IF NOT EOLN (HarksFile) !~M ~§!~- READ (MarksFile, eh); !E eh = ' , !~~M spaee := TRUE; IF (eh )= '0') AND (eh (= '9') !~~M --!E spaee = TRÜE-!~M !!~§!M WRITE (CleanFile, • ~, eh); space := FAL5E ~M~ ~b§~ WRITE (CleanFile. eh) "'~!1 ~b§'" !!~§!M WRITELN (CleanFile); space := FALSE; lineCount := SUCC (lineCount); READ (MarksFile, eh) <* EOLN component *) END ~M!i;- !E lineCount = numForms - 1 I~~~ !!~§!M WRITELN (CleanFile); WRITELN ('Last EOLN misslng. Now supplied~) ~~~; !E lineCount < numForms - 1 !~~~ WRITELN (~Too few forms~); WRITELN ('Completed'); RESET (CleanFile) ~M~· 8.2 One solution to this problem is to read the ftle character by character instead of integer by integer. The integers can be formed bya statement: mark := mark * 10 + digit Each mark is complete when aspace is read or when EOLN is detected. The resulting program would be a mixture of AverageMarks and OeanData above. 8.3 The exercise wams that a common error could be the omission of a relevant number. The effect of this would be to put the input 'out of step'. When this happens, real numbers might be read when integers were 259 expected. If the program calls for READing an integer and the data offered is real, control could switch from the program to the implementation's diagnostics. This would probably halt the program before any desired error message had been output. In such circumstances it is probably better to read all numbers as real numbers and to test the integers with a statement such as 1E A8S (number) - TRUNC (ASS In order to facilitate the location of errors, it is desirable to be able to output, in the error message, the last data that was apparently successfully read. In this exercise this would be the customer's number and the last pair of itemjquantity. Thus each of these should be retained untU its successor had been successfully read. The other requirements of this exercise should present few difficulties. CHAPTER9 9.1 E8Q§8fH'1 anagrams (INPUT. OUTPUT); ~Q~§! wordsPerLine = 6; VAR n. numLetters. wordCount : INTEGER; inBuffer~ outBuffer : E'B~~~~ B138BY [1 ~~ 7] QE CHAR; E'I3Q~~~~B~ selectChar (charNum : INTEGER); ~~B n. m : INTEGER. ~!.';§!t'! EQ8 n := 1 !Q numLetters ~Q !E inBuffer [n) <> • ~ !~~~ ~!.';§!t'! outBuffer [charNuml := inBuffer [n); inBuffer (0) := !E charNum = numLetters !~~~ ~!.';§!t'! EQB m := 1 !Q numLetters QQ WRITE (outBuffer [ml); EQB m := numLetters + 1 IQ 10 QQ WRITE (~ ~); wordCount := SUCC (wordCount); 1E' wordCount ~QQ wordsPerLine = (I I~~~ WRITELN !.';t'!!) !;bS~ selectChar· (charNum + 1); <* recurSlve call') inBuffer [n] := outBuffer [charNum); !.';t'!!) r;:~Q; ~!.';§!t'! n := 0; wordCount := 0; WRITELN (~Enter your word~); ~~!b!.'; (t'!QI EOLN (INPUT» Bt'!!) (n < 7) !)Q ~!.';§!t'! n := SUCC (n); READ (inBuffer [n) !.';@; numLetters := n; selectChar (1); WRITELN; WRITELN (~Number of anagrams wordcount 5) !.';t'!!). 260 9.2 r8Q§88~ InvoicePrep (OUTPUT~ PriceList. CustPurchases); ,{im position: INTEGER: itemNum: 888a'!' [1 .. 100] QE INTEGER: prlce: 8888Y [1 .. 100] QE REAL: E~~~!!g~ Ioeation (number : INTEGER) INTEGER, '{e8 INTEGER; found : BOOLEAN; !!!;!W" found := FALSE; n : = 1; 8!;e!;eI !E itemNurn [n) = number !~~~ found TRUE: n := SUCC (n) ~~I!b found Q8 (n > 100); !E found !~~~ Ioeation PRED (n) Eb§~ Ioeation := n ~~~; RESET (PriceList); RESET (CustPurchases); EQ8 item := 1 IQ 100 QQ READ (PriceList, itemNum eitern], price eitern]); i nvTotal : = 0; READ (CustPurchases, item); ~~!b~ item <> 0 QQ !!!;§.!I'! READ (CustPurchases, qty); WRITE (itern :4, qty :12 :3); position := Ioeation (itern); !E (position> 0) 8~Q (position <= 100) !~~~ !!!;§!!'! extension := qty * price [position]; WRITELN (price [position] :12 :2, extension :12 :2); invTotal := invTotal + extension !;!'!Q ~L§~ WRITELN (~Item no~, item, ~not recognised~); For the second approach, the following changes would have to be made to the above program : itemPrice e88e:t [1 •• 2, 1 •• 100] QE INTEGER; 8~e~eI IF itemPrice [1, n] = number !~~~ found := TRUE; n := SUCC (n) !d!'!I!b found Q8 (n > 100), Ioeation := n !;!'!Q, RESET (PriceList); RESET (CustPurchases); EQ8 item := 1 IQ 100 QQ EQ8 n := 1 IQ 2 QQ READ (PriceList, itemPrice [n, item]); 261 i nvTotal : = 0; READ (CustPurchases. i tem); ~~!~!;: item <> 0 ~Q ~S§!t'I READ (CustPurchases~ qty); WRITE (itern :4, qty :12 :3); position := Ioeation (itern); !E CHAPTER 10 10.1 The solution to the first part ofthis exercise is similar to the loeation function of Exercise 9.2. For the second part of this exercise, the Boolean declaration found could be replaced by two Boolean variables: foundEqual and found Greater. The tests would be !E itemNurn [n] number !t!~~ foundEqual := TRUE; 1E itemNum [n] number !t!~~ foundGreater:= TRUE; and the output would be lE foundEqual !t!~~ WRITELN (~Index = , PRED (n) : 1) ~b§~ !E foundGreater AND (n :> 2) THEN WRITELN (~Number iS-b;tween indi~;~ n - 2 :1, .' and~, PRED (n) : I' ~b§~ WRITELN (~Number out of range~) 102 For these three solutions it is assumed that an integer array list f 1 .. 1000J has been declared globally. E8Q~~Q~B~ bubbleSort (last: INTEGER); "'f!~ m, n, temp : INTEGER; EQ~ n := (last - I) QQ~t'lIQ 1 QQ EQ~ m := 1 IQ n QQ !E list[m] > list[m+l] It1E;~ ~S§!t'I temp := list[m]; list[m] := list[m+l]; list[m+l] := temp !:':t'lQ EBg~EQ~BE selectionSort (last: INTEGER); "'f!~ index, temp, k, m, n INTEGER; ~s§!~ EQ~ n := last Q~~IQ 2 QQ 262 "'!;!w'! temp := - MAXINT; EQ8 m := 1 IQ n QQ IE list [m] > temp !~~~ ll!;§H! temp := list [m]; index := m !;!'!Q; EQB k := index IQ n QQ list [kJ list [k+lJ; list [n] := temp !;!'!Q ~~Q; E8Q~~Q~8~ insertionSort (last INTEGER) ; "'fl8 temp, k, m, n INTEGER; ll!;§!!'! EQB n := 2 !Q last QQ !E list [n] < list (n-l] I~~~ ll!;§!!'! temp := list [n]; m := 1; ~~!b~ temp > list [mJ QQ m := SUCC (m); EQ8 k := n QQ!'!!'!IQ m+l QQ list [kJ := list [k-1J; list [mJ := temp t;;!,!Q t;;!,!Q; CHAPTER 11 11.1 EBQ§BB~ Sorting (INPUT, OUTPUT, Resultsl; list : fl88flY [1 .. 1000J QE INTEGER; seed, n, last : INTEGER; Results : TEXT; EBQ~~Q~8~ inSeed (~B8 seed INTEGER) ; EXTERNAL; (* Chapter 7 *) E~~~I!Q~ random (~e8 seed INTEGER; ma>: INTEGER) INTEGER; EXTERNAL; (* Chapter 7 *) E8Q~t;;Q~8t;; sort (last: INTEGER); EXTERNAL; <* Here insert the procedure under test .> llt;;§!!'! inSeed (seed); REWRITE (Resul ts); WRITE ('How many numbers ? »: READ (last); EQ8 n := 1 !Q last QQ list [n] := random (seed .. 100(0); WRITELN (~press 11.2 This exercise is a matter of developing the program already out lined in the text. CHAPTER 16 16.1 Because the function deal would be called when the pack was already empty. The expression card !~ cardPack would never be true, however many random numbers were generated. 16.2 fBQGBB~ Shopp i ng I! NPUT. OUTPUT>, HEs commodltv = (apples. bread. cream. damsons. eggs, flour, qammon. h~m. icecream. jam); commset ~~I Q~ commoditv; YB8 shop. aL~st. bList. CLlst. aBasket. bBasket. cBas~· et. dBasket. basket : commset; n : cQmmodity: commset; initial CHAR) , ~B8 comm commodlty; !ls!W~! 1 i st : == []; WRITELN (' Enter Initial. ~~~s shopping list. numbers~); ~~!bs ~QI EOLN ~Q lisGm READ (comm); list := list + [commJ END, WRITELN ~~g; m;;G!~ shop := [damsons, egg5, flour, gamman, harn, icecream, jam]; PAGE; WRITELN (~Commodities are:~); WRITELN ('0. Apples 1. Bread 2. Cream 3 ... Damsons'); WRITELN ('4. Eggs 5. Flour b. Gammon 7 ... Ham'); WRITELN ('8. Icecr-eam 9. J~m'); WRITELN, inputList (aList, 'A'); inputList (bList, 'B~); cList ;= [ garnrnon, harn, icecream, jam ]; aBasket := aList * shop; bBasket := bList * shop; cBasket ;= cList * aBasket; aBasket ;= aBasket - cList; basket ;= cList * bBasket; cBasket ;= cBasket + basket; bBasket := bBasket - cList; !E aBasket = bBasket I~~ dBasket ,= aBasket EL~ dBasket ;= shop - cBasket; WRITELN (70iana~~s basket contains:~); !E dBasket = [] I~~ WRITELN ('nothing') sb§S 264 FOR n := damsons TO jam DO --IE n !~ dBasket-I~~~ - !;e§~ n QE damsons WRITELN ('Oamsons'); eggs WRITELN ('Eggs'); flour WRITELN ('Flour'); gamman WRITELN ('Gamman'); ham WRITELN ('Harn'); icecream WRITELN ('Ieecream'); jam WRITELN ('Jam') ~~Q ~~Q. INDEX ABS, 89 comment,19 actual parameter, 78 compatibility of types, 172 addition, 24 set types, 202 of sets, 198 compile time errors, 26 AND,63 compiler, 10 ARCTAN, 89 components of array, 108 ARRAY, 108 compound statement, 30 arrays, 107 conformant array parameters, 206 multidimensional, 110 CONST,19 ASCII, 61, 252 constant, 17 assignment statement, 20 definition, 30 compatible, 26, 172 COS, 89 symbol,20 data structure, 173 type, 165 back-up memory, 5 debugging, 234 BEGIN, 20 declarations, 19 bibliography, 254 decrementation,38 binary ranging, 58 default field width, 33 search,123 definitions, 1 9 block,30 delay, 77 BOOLEAN,71 delimiters, 21 Boolean expression, 44 deviation, standard, 150 operators, 63 diagnostics, 234 variables, 70 difference of sets, 198 braces, 19 direct memory access, 223 brackets, 22 DISPOSE, 195, 209 British Standard 6192: 1982, 10 distribution, Poisson, 145 bubble sort, 118 normal or Gaussian, 149 buffer variable, 98, 205 DIV,24 business charts, 162 division, 24 byte, 204 by zero, 26 DO,36 call,76 documentation, 11 carriage return, 21 DOWNTO, 38 CASE,68 dumb terminal, 2 case label, 69 dynamic variables, 191 cassette, 6 central processing unit, 4 editor, 9 CHAR,61 elements of array, 108 character string, 20 of Pascal program, 18 set, 60 ELSE,66 variable, 61 END,21 CHR, 63, 89 end of file, 94 colon, 22 of line, 100 comma,22 enumerated type, 169 266 EOF, 94 index, 107 EOLN, 100 INPUT,19 executive, 217 insertion sort, 119 EXP, 89 inspection, 92 expression, 20 INTEGER,25 EXTERNAL, 82 integers, I 7 external files, 92 intelligent terminal, 3 interactive input, 248 FALSE,71 intermediate code interpreter, 13 false, 44 interpreter, 10 fie1d, 179 interrupt, 221 width parameters, 31 intersection of sets, 199 width, integers, 32 iterative structures, 36 width, real, 33 width, with strings, 34 key for sorting, 122 FIFO (first in first out), 195 keyboard,7 FILE,95 fixed format, 177 LABEL,210 part, 185 lable, GOTO, 209 floating point, 17 case, 69 FOR,36 languages, programming, 9 form feed, 102 layout of programs, 23 formal parameter, 78 left associative, 42 format, output, 31 levels in functions and procedures, FORWARD,87 87 free format, 177 in program writing, 128 union, 208 of language, 9 fuH stop, 23 UFO (last in, first out) stack, 123 FUNCTION,76 linear search, 123 function, 74 linke d lists, 1 87 dec1aration, 76 list, 21 as parameter, 206 LN,89 rules,83 loading a program, 6 local constants and variables, 79 Gaussian distribution, 149 low levellanguage, 9 generation, 92 GET,205 machine code, 9 global constants and variables, 80 magnetic discs and tapes, 6 GOTO,209 MAXINT, 35 graphics, 157 memory, 5 economy, 233 hardware, 10 merging, 1 23 high levellanguage, 9 microcomputer,3 'MicroProcessor Pascal', 223 iden tifiers, 15 minicomputer, 3 IF,48 Mon, 24 immediate access memory, 5 modulus,24 implementation, II multi-programming, 224 dependent, 11 multi-tasking, 213 IN, 199 multi dimensional arrays, 110 incrementation, 37 mutual recursion, 86 267 nesting of 100ps, 38 programming languages, 9 NEW, 191,208 strategy, 126 SYMBOLS IN ASCII ORDER , , (quotes), 20 j,24 ( ),22 :,22 (* *), 19 : =, 20 (. .),108,198 < < = < > = > > =, 44 *,21 @, 191,205 +, 24 [],108,198 , (comma), 22 t, 191,205 -,24 {},19 . (full stop), 22 269 PROGRAMS, FUNCTIONS AND PROCEDURES AverageMarks, 101 Napierian, 52 NewRoulette, 74, 82 BinaryRanging, 58 NewtonRaphson, 57 NormaIDistribution, 153 Characters, 61 NumberTypes, 25 CharHandling, 249 CharString, 62 PackOfCards, 165 CircleA rea, 14 Payroll,36 CircleA rea2, 18 Payro1l2,46 CustSort, 178 Payro1l3,95 PersonnelRecords, 181 Damped2, 160 Poisson, 146 DampedOscillation, 157 Primefactors, 85 DealPack,201 Delay,41 quickSort, 137 delay, 77 delay (extended period), 78 Random, 49 DEMO, 228 random, 79 DisplayAcross, 39 ReadTest, 113 ReverseOrder, 85 Exercise31,40 Roulette, 64 Exercise32a, 40 Exercise32b,40 sheliSort, 137 SmallestReal, 45 FlyTrap, 163 Spiral, 159 Football,147 Squares, 38 StringTest, 113 IfEIse, 68 inSeed,81 InvoicePrep, 108 Tru eFalse , 72 TwoDice, 142 Logarithml, 53 Logarithm2, 53 Wordsl, 187 Logarithm3, 55 Words2,192 Maximuminteger, 28 yesNo, 74