Problem solving and structured programming in BASIC

This document was uploaded by one of our users. The uploader already confirmed that they had the permission to publish it. If you are author/publisher or own the copyright of this documents, please report to us by using this DMCA report form.

Simply click on the Download Book button.

Yes, Book downloads on Ebookily are 100% Free.

Sometimes the book is free on Amazon As well, so go ahead and hit "Search on Amazon"

Author(s): Elliot B. Koffman, Frank L. Friedman
Publisher: Addison - Wesley
Year: 1979

Language: English
Pages: 466

Background ......Page 8
BASIC Syntax ......Page 9
Textbook Organization ......Page 10
Acknowledgments ......Page 12
CONTENTS ......Page 14
1. INTRODUCTION ......Page 18
1.1 Computer organization ......Page 19
1.2 Programs and programming languages ......Page 24
1.3 Introduction to BASIC ......Page 26
1.4 Using the computer ......Page 35
1.5 Additional input and output features ......Page 39
1.6 Summary ......Page 44
Programming problems ......Page 45
2. PROBLEM SOLVING WITH THE COMPUTER ......Page 48
2.1 Program analysis ......Page 49
2.2 Description of the problem solution ......Page 51
2.3 Algorithms involving decisions and loops ......Page 56
2.4 Implementing algorithms as programs ......Page 69
2.5 Debugging a BASIC program ......Page 71
2.6 Summary ......Page 75
Programming problems ......Page 77
3. FUNDAMENTAL CONTROL STRUCTURES ......Page 78
3.1 Introduction to control structures ......Page 79
3.2 Decision structures ......Page 80
3.3 The BASIC FOR loop ......Page 96
3.4 The widget inventory control problem ......Page 103
3.5 Comments on program form and programming style ......Page 107
3.6 Common programming errors ......Page 108
3.7 Summary ......Page 109
Programming problems ......Page 113
4. EXPRESSIONS, STRINGS, AND BUILT-IN FUNCTIONS ......Page 116
4.2 Generalizing the assignment statement ......Page 117
4.3 String data and string variables ......Page 123
4.4 A sample problem – the registered voters list ......Page 125
4.5 Functions ......Page 129
4.6 The prime number problem ......Page 135
4.7 Numerical errors ......Page 138
4.8 Common programming errors ......Page 140
4.9 Summary ......Page 141
Programming problems ......Page 142
5. THE WHILE LOOP, TOP-DOWN PROGRAMMING AND SUBROUTINES ......Page 146
5.2 The WHILE loop structure ......Page 147
5.3 Illustrations of algorithm development using the WHILE loop ......Page 154
5.4 Top-down programming ......Page 164
5.5 Applications of top-down programming ......Page 169
5.6 Common programming errors ......Page 178
Programming problems ......Page 180
6. ARRAYS AND SUBSCRIPTS ......Page 184
6.2 Declaring arrays ......Page 185
6.3 Array subscripts ......Page 187
6.4 Manipulating arrays ......Page 189
6.5 Searching an array ......Page 205
6.6 Additional techniques for processing selected array elements ......Page 213
6.7 Common programming errors ......Page 215
6.8 Summary ......Page 216
Programming problems ......Page 218
7. NESTED AND MULTIPLE-ALTERNATIVE STRUCTURES ......Page 224
7.2 Nested structures ......Page 225
7.3 The multiple-alternative decision and SELECT structure ......Page 230
7.4 The bowling problem ......Page 238
7.5 The ON-GOTO and ON-GOSUB statements ......Page 243
7.6 Nested loops ......Page 246
7.7 Sorting an array ......Page 249
7.8 Common programming errors ......Page 255
7.9 Summary ......Page 257
Programming problems ......Page 260
8. LARGER PROBLEMS: USER-DEFINED FUNCTIONS, SUBROUTINES AND SUBPROGRAMS ......Page 266
8.2 User-defined functions ......Page 267
8.3 Solving a larger problem – the simple statistics problem ......Page 277
8.4 Subprograms ......Page 286
8.5 Common programming errors ......Page 292
8.6 Summary ......Page 293
Programming problems ......Page 296
9. CHARACTER STRING MANIPULATION ......Page 304
9.2 The length of a character string ......Page 305
9.3 Substrings ......Page 307
9.4 Concatenation of strings ......Page 312
9.5 String expressions and comparisons ......Page 313
9.6 Searching for a substring ......Page 318
9.7 Manipulating individual characters in a string ......Page 320
9.8 Sample problems ......Page 324
9.9 Common programming errors ......Page 338
Programming problems ......Page 341
10. TWO-DIMENSIONAL ARRAYS AND MATRICES ......Page 348
10.2 Declaration of two-dimensional arrays ......Page 349
10.3 Manipulation of two-dimensional arrays ......Page 350
10.4 Matrix operators ......Page 356
10.5 Additional applications of two-dimensional arrays ......Page 365
10.6 Common programming errors ......Page 374
10.7 Summary ......Page 375
Programming problems ......Page 377
11. FORMATTED OUTPUT AND FILES ......Page 380
11.2 Formatted output: PRING USING and image features ......Page 381
11.3 Files ......Page 387
11.4 Application of sequential files ......Page 396
11.5 Random access files ......Page 402
11.6 Chaining ......Page 404
11.7 Common programming errors ......Page 405
Programming problems ......Page 409
GLOSSARY BASIC STATEMENTS AND STRUCTURES ......Page 414
ANSWERS ......Page 426
INDEX ......Page 458