| Preface |
|
ix | |
| Introduction |
|
1 | (8) |
| Why program at all? |
|
1 | (1) |
| Why C? |
|
2 | (1) |
| The programming environment |
|
2 | (1) |
| A simple C program |
|
3 | (2) |
| Types of error |
|
5 | (1) |
| Program data |
|
5 | (1) |
| Testing and debugging |
|
6 | (1) |
| Programming in the large |
|
6 | (3) |
|
1 Getting information in and out |
|
|
9 | (17) |
|
1.1 Getting information into a program |
|
|
9 | (3) |
|
|
|
12 | (1) |
|
1.3 Variables and declarations |
|
|
13 | (2) |
|
1.4 Getting information out of a program: Simple output |
|
|
15 | (4) |
|
1.5 Getting information out of a program: Formatted output |
|
|
19 | (1) |
|
|
|
20 | (2) |
|
1.7 Testing and debugging |
|
|
22 | (1) |
|
|
|
22 | (1) |
|
|
|
23 | (3) |
|
|
|
26 | (19) |
|
2.1 Assignment statements |
|
|
26 | (1) |
|
2.2 The use of simple arithmetic expressions |
|
|
27 | (1) |
|
2.3 Some alternative syntax |
|
|
28 | (1) |
|
2.4 More about arithmetic expressions: Order of evaluation |
|
|
29 | (4) |
|
|
|
33 | (2) |
|
2.6 More about int and float variables |
|
|
35 | (3) |
|
|
|
38 | (3) |
|
|
|
41 | (1) |
|
|
|
42 | (3) |
|
|
|
45 | (21) |
|
|
|
45 | (4) |
|
3.2 Simple if-else statements |
|
|
49 | (1) |
|
3.3 The use of compound statements |
|
|
50 | (4) |
|
3.4 More complicated conditions |
|
|
54 | (1) |
|
3.5 Definition of the logical operators |
|
|
55 | (1) |
|
3.6 Logical values and variables |
|
|
56 | (4) |
|
3.7 Selecting one of many alternatives |
|
|
60 | (3) |
|
|
|
63 | (1) |
|
|
|
64 | (2) |
|
4 Simple counter-controlled loops |
|
|
66 | (14) |
|
|
|
66 | (1) |
|
4.2 Simple for statements |
|
|
67 | (3) |
|
4.3 Syntax of the for statement |
|
|
70 | (1) |
|
4.4 Loan repayment example |
|
|
71 | (2) |
|
4.5 Making use of the control variable |
|
|
73 | (2) |
|
4.6 Other features of the for statement |
|
|
75 | (1) |
|
4.7 Programs with more than one simple loop |
|
|
76 | (1) |
|
|
|
77 | (1) |
|
|
|
78 | (2) |
|
|
|
80 | (24) |
|
|
|
80 | (1) |
|
|
|
80 | (4) |
|
5.3 Reading data from text files |
|
|
84 | (2) |
|
5.4 while loops versus do loops |
|
|
86 | (3) |
|
5.5 Multiple terminating conditions |
|
|
89 | (2) |
|
|
|
91 | (5) |
|
5.7 Detecting the end of a data file |
|
|
96 | (1) |
|
5.8 Use of logical variables |
|
|
97 | (2) |
|
|
|
99 | (2) |
|
|
|
101 | (3) |
|
6 Statements within statements |
|
|
104 | (21) |
|
6.1 Conditional statements within loops |
|
|
104 | (4) |
|
|
|
108 | (5) |
|
|
|
113 | (5) |
|
6.4 Data validation: Guarding a program |
|
|
118 | (3) |
|
|
|
121 | (1) |
|
|
|
122 | (1) |
|
|
|
123 | (2) |
|
7 Giving a process a name |
|
|
125 | (18) |
|
7.1 Simple void functions |
|
|
125 | (1) |
|
7.2 Void functions with parameters |
|
|
126 | (4) |
|
|
|
130 | (7) |
|
7.4 Functions with results |
|
|
137 | (2) |
|
|
|
139 | (2) |
|
|
|
141 | (2) |
|
8 Working with characters |
|
|
143 | (20) |
|
8.1 Character variables and character input |
|
|
143 | (3) |
|
8.2 Character as function parameters |
|
|
146 | (2) |
|
8.3 Reading character data from files |
|
|
148 | (1) |
|
|
|
148 | (6) |
|
8.5 Further facilities for character manipulation |
|
|
154 | (5) |
|
|
|
159 | (1) |
|
|
|
160 | (3) |
|
9 Collections of values: Arrays |
|
|
163 | (26) |
|
9.1 One-dimensional arrays |
|
|
163 | (2) |
|
9.2 Sequential access to one-dimensional arrays |
|
|
165 | (5) |
|
9.3 Arrays of characters: Strings |
|
|
170 | (2) |
|
9.4 Subscript range errors |
|
|
172 | (1) |
|
9.5 Random access to one-dimensional arrays |
|
|
172 | (5) |
|
|
|
177 | (3) |
|
9.7 Two-dimensional arrays |
|
|
180 | (5) |
|
|
|
185 | (1) |
|
|
|
186 | (3) |
|
10 Collections of values: Structures |
|
|
189 | (22) |
|
|
|
189 | (4) |
|
10.2 Tables: Arrays of structures |
|
|
193 | (3) |
|
10.3 Structures compared with other variable types |
|
|
196 | (2) |
|
10.4 Structures as parameters |
|
|
198 | (3) |
|
|
|
201 | (3) |
|
|
|
204 | (4) |
|
|
|
208 | (1) |
|
|
|
209 | (2) |
| Appendix A C keywords |
|
211 | (1) |
| Appendix B Arithmetic, relational and logical operators |
|
212 | (1) |
| Appendix C Some library functions |
|
213 | (4) |
| Index |
|
217 | |