Preface
Problem Solving and Structured Programming with Pascal is designed for a first course in problem solving and computer programming gin which Pascal is the programming language. No previous knowledge of programming is presumed. The mathematics backgr ound required is that equivalent to three years of high school mathematics or a course in college algebra and trigonometry.
Our aim in writing this book is to help teach students the skills and concepts needed to become good problem solvers capable of using the Pascal language well. Not until these skills are developed is the Pascal language presented? Subsequently, as more powerful aspects of the language are developed, so are good programming techniques--all based on the solid foundation of problem solving and algorithm development presented in the first chapter.
Algorithm and program development is presented from the top-down approach. Students learn how to produce precise statements of problems as well as analyze input and output requirements. They are taught techniques for developing problem solutions in modules and introduced early to the concept of subprograms in Pascal. As Students learn the programming phase of problem solving, they are taught how to design and test each module individually first, then put modules together in a single program that pr oduces the required results. As a consequence of out approach, students should develop confidence in solving any problem presented to them and should be able to produce good, understandable solutions to such problems in which the computer is the major too l.
All program examples in this book have been run on a DEC VAX11/750 computer system running under DEC's RMS operating system. Any file processing done in the programs is, therefore, done according to the requirements of the VAX11/750.
To provide a guide to the pedagogical development used, we now review the approach taken in each chapter. In Chapter 1, the fundamental concepts of problem solving are discussed quite apart from any programming language features. Four phases of pr oblem solving--precisely defining the problem, analyzing the input and output requirements, developing the solution algorithm, and developing the Pascal program--are presented, as is the top-down approach to problem solving. Considerable time is devoted t o algorithms, their properties, their modular development, and methods for representing them.
Chapter 2 presents some elementary programming language concepts with particular emphasis on how they occur in Pascal. The standard data types, and how to make Pascal declarations that relate to each of them, are discussed. Elementary input and out put concepts are explained, as well as other features of Pascal needed to be able to write a simple but complete program. Chapter 3 leads the student into the basics of control structures, such as the if-then-else, for-loop, while-loop, and repeat-unti l structures.
Chapter 4 takes a careful look at program errors and often-overlooked concepts related to that topic. Three kinds of program errors (syntax, logic, and run-time) are discussed, and techniques are introduced to prevent them in the first place. Metho ds for locating and removing the errors, if they do occur, are also presented. Actual programmed examples are analyzed for various errors, and students are shown how to debug them. No new Pascal concepts are introduced in this chapter, so if lack of time prevents its inclusion in the course, students will not miss any aspects of the Pascal language. However, the authors have found it important to formally discuss in class the occurrence and removal of program errors.
Subprograms are introduced in Chapter 5, as well as the syntax and application of functions and procedures in Pascal. From this point on in the book, modular programming is emphasized and examples are given to reinforce that principle.
Array declarations and applications are considered in Chapter 6, as are text files and the processing of text files. After thorough instruction in the topics in this chapter, students will be able to write programs more like those developed by p rofessional applications programmers.
In Chapter 7, we discuss advanced topics related to control structures. Specifically, the following capabilities of Pascal are taught: case structure, If-then-else-if structure, and nested loops. Several complete programming examples illustrate thes e concepts.
Advanced topics related to functions and procedures are the focus of Chapter 8. Various kinds of parameters are discussed, in particular, the use of functions and procedures as parameters. The important concept of recursion and recursive subprograms is a significant part of this chapter. Diagrams and examples are carefully presented to make this vital topic lucid for the student.
Chapter 9 is devoted to advanced concepts related to structured data types. In particular, we discuss records, linked lists using pointer-type data, and files of records. If the course being offered is intended primarily to teach the fundamental fea tures of the Pascal language, the instructor may choose to omit the sections on linked lists and pointer-type data.
Finally, Chapter 10 contains some basic concepts of data structures such as stacks, queues, linked lists, and binary trees. Examples are given to illustrate the implementation and processing of these data structures in Pascal. If time does not permi t, this chapter may be omitted from a course in problem solving and Pascal programming. Nevertheless, we believe that if students are introduced to these concepts at the end of such a course, they will be better prepared to progress through successive com puter science courses, However, if the students are not primarily majors in computer science, this chapter should probably be omitted.
Appendix A is a list of all standard Pascal functions, procedures, and identifiers, as well as a list of all reserved words. Anyone who has taught a course in Pascal will appreciate this ready reference of these facts.
Syntax diagrams are the topic of Appendix B. Every Pascal statement structure is clearly described by means of a syntax diagram. Any questions regarding the punctuation or use of reserved words in any Pascal statement can be answered by referring to the appropriate section of this appendix. Diagrams are arranged alphabetically by the word normally used to identify a given Pascal statement.
Included among the unusual features of this book are the following:
Many helpful suggestions were made by the reviewers of this manuscript, almost all of which were incorporated in the final version. We extend sincere thanks to Andrew Batts, Murray State University; Dwight Caughfield, Abilene Christian University; Jame s Clark, University of Tennessee-Martin; Henry Etlinger, Rochester Institute of Technology; Joe Grimes, California State University-San Luis Obispo; Norman Lindquist, Saint Andrews College; George Medelinskas, North Shore community College; Clinton Smulle n, University of Tennessee-Chattanooga; and Allan Tharp, North Carolina State University. Their thoughtful comments and creative ideas went far toward making this book as useful as we hope it will be.
Ali Behforooz
Martin O. Holoien