Preface

Since the introduction of the PC's (Personal Computers) in the fall of 1981, computers have found their applications in all walks of life. At present they no more remain the tools of only scientists or engineers. They are being used to solve problems of varying complexities by every one. A problem could be as simple as ‘finding out the area of a triangle, given its three sides’ or ‘converting the temperature given in degrees Fahrenheit into temperature in degrees Celsius’. Also, a problem could be as complex as ‘controlling the trajectory of a missile’ or ‘in weather forecasting’. In any case, the digital computer does not figure out its own solution to problems, but must be told exactly how to solve any given problem as well as how to make all decisions. Preparing a list of instructions, which tells the computer how to perform its calculations and take decisions, is called programming. Therefore, in order to write a program one has to have sufficient ‘knowledge’ about how to solve the problem. In other words, one should know the ‘procedure’ for solving the problem otherwise. Here, otherwise means without using computers i.e. may be using a pen and a piece of paper. Thus knowing the procedure means knowing the method of solving the problem.

After having knowledge about the method or the technique, to be used to solve a problem, the first step is to determine the sequence of operations required to solve the problem. These sequences of operations are documented either by listing the steps involved sequentially using some natural language like English or represented diagrammatically as flow diagrams or flowcharts. As the visual approach makes it easy for beginners to follow the method or procedure of solving problems, flowcharts have been developed for all the examples discussed in this book. The next step in solving a problem using computers is to code the method using any of the computer languages like Java, Fortran, C, Pascal etc. Obviously, to solve problems, of whatever complexity using computers, one has to learn a specific computer language in order to code the problem solving procedure. As such, beginners generally concentrate on learning some computer language initially. With an eagerness to pick up the syntax and semantics of the language, less attention will be given to pick up the techniques of problem solving. This is why, in this book, I am concentrating on the problem solving procedures and techniques rather than getting trapped in the vicious circle of just learning a language. Nevertheless, complete C programs have been presented to all the examples discussed in this book along with the just required C details, in the form of C tips. However, in latter chapters, as more details of C are required, a section called … beyond that discusses more C specific details has been included. Some examples, in these latter chapters, deal with techniques of C handling for problem solving rather than general problem solving techniques. In any case, the reader is advised to enter the code into the machine directly, without bothering much about the intricacies of the programming language, compile and run the programs. By the time a reader comes to the end of the book, I am sure that, he/she not only will be really capable to think in terms of some plausible problem solving techniques but also will be quite comfortable in coding using C. If necessary any standard textbook on ANSI C may be referred to for more details of the C language.

For many problems, several possible methods of solving them do exist. Some are more efficient than the others, some are more tolerant of unexpected data than others are and some are easier to code in a computer language or are less prone to programming errors. Only the methods, which are easily comprehendible to the beginners, have been considered in this book. No much concern has been shown towards really efficient techniques.

As the target readers of this book are beginners, most of the material presented here is elementary in nature. The material has been organized into various chapters of increasing complexity. Every chapter begins with a brief introduction that gives an idea about the problems discussed in that particular chapter and ends with a list of problems in the form of exercises.

As the first step in problem solving is to develop an algorithm or a flowchart that encapsulates the procedure of solving the problem, algorithms and flowcharts have been introduced in Chapter 1. Also the necessity and importance of dividing a problem into sub-problems and solving these sub-problems independently which helps a problem solver in obtaining the final solution of the problem is explained in this chapter.

Chapter 2 discusses the solving of very simple problems. This chapter deals with the technique of taking data values into the computer, taking out the results and the use of very popular and widely used library functions. All the steps or instructions of the programs discussed in this chapter are executed strictly sequentially. Problems that need basic two ways and three way decision making are discussed in Chapter 3.

Quite often we come across problems that need repeated execution of certain steps during a problem solving process. Chapter 4 discusses the techniques for repeated execution of certain steps or instructions using what are known as iterative techniques. Problems that need multiway decision making are dealt with in Chapter 5.

Many applications need the processing of a collection of data items of similar characteristics, called arrays. Techniques for handling arrays are discussed in Chapter 6.

Text processing is also one of the important activities that are performed with computers. Chapter 7 discusses the techniques for handling texts that are made up of characters and character strings.

As problems grow in size it is natural to divide the problem in to sub-problems and to first solve these sub-problems independently and then solve the complete problem by putting the solutions of these sub-problems together. Techniques for handling sub- problems (called functions in C) and tailoring them into a single unit (called main( ) in C) are discussed in Chapter 8.

Chapters 9 and 10 deal with pointers and structures respectively at an introductory level. Actually these topics are slightly advanced in nature and may not be easily comprehendible by beginners. However, these topics have been included for the sake of completeness and as an indicator for further study.

This book is for anyone who has plus-two level knowledge in mathematics (except the calculus) and is interested in using computers or keen in pursuing college or diploma studies.

M. G. Venkateshmurthy

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.118.2.240