Contents

Preface xi 1 Pascal Programming Structures 1 Introduction 1 Language History 2 Problem Solving 3 Pascal Fundamentals 3 Functional Units of a Computer 4 Indentifiers 5 Variables and Constants 7 Variable Declaration and Data Types 8 interger 8 Real 8 Character 8 Boolean 9 Text 9 Var Declaration 9 Const Declaration 10 Important Notes 11 Input: Read(Readln) Statements 12 Output:Write(Writeln)statements 14 Arithmetic Expressions 15 Assignment Statement 16 Pascal Library Functions 17 Program Structures 19 Block Structure 20 Selection Structures 21 Relational Expressions 21 Boolean Expressions 22 Two-way Selection Structures 23 Multiway Selection Structures 23 Internal Documentation; Comments 29 Iteration Structures 30 Counter-controlled Iteration Structure: The For Statement 30 Condition-controlled iteration Structure: The While Statement 32 Conditioned-controlled Iteration Structure: The Repeat Statement 34 Nested Iterations 36 Function and Procedure Subprograms 38 Function Subprogram 38 Procedure Subprogram 41 Subprogram Linkage 43 Actual and Formal Arguments or Parameters 44 Recursive Subprograms 45 2 Pascal Data Structures 51 Introduction 51 Type Declarations 52 User-defined Scalar Enumerated Data Type 52 Succ, Pred, and Ord Functions 54 Impoenmentation of Enumerated Data Type 55 User-defined Scalar Subrange Data Type 55 Structured Data Types:Arrays 57 Array Declaration:One-dimensional Arrays 57 Array Declaration:Multidimensional Arrays 58 Structured Data Types; Records 64 Record Structure 65 Variable-length Records 67 Array of Records 68 With Statement 69 Structured Data Types: Files 73 File Processing 75 reset(F) 75 rewrite(F) 75 get(F) 75 put(F) 75 eof(F) 75 read(F,Vrl) 77 write(F,Vrl) 77 Text Files 81 eoln(F) 81 readln(F) 81 writeln(F) 82 File of Records 82 Structured Data Types:Sets 85 Set Operations 86 Set Expressions 86 Pointer Type 89 GOTO and Labels 105 3 Some Nonstandard Features of Pascal 106 Introduction 106 append 106 blockread/blockwrite 107 bufferread/bufferwrite 107 case with else or otherwise 108 clock 108 date 108 close 109 concat 109 copy 109 delete 110 exit 110 extern or external 110 fillchar 111 gotoxy 111 halt 111 insert 112 length 112 pos 112 scan 113 setpointer 114 sizeof 114 string 114 time 115 treesearch 115 Appendix A 116 Standard pascal Functions 116 Standard Pascal Procedures 117 Pascal Reserved Words 118 Standard Identifiers 118 ASCII and EBCDIC Codes 118 Index 123