Chapter 1 Programming Fundamentals 1
Lesson 1.1 Programming Languages 1
1.1.1 Assembly Language 1
1.1.2 High Level Languages 2
Lesson 1.2 Software Engineering 4
1.2.1 Top-down Modular Design 5
Lesson 1.3 The C Language,ANSI C and C Compilers 7
1.3.1 C and ANSI C 7
1.3.2 Program Development 8
Lesson 1.4 Using Bits to Represent Characters and Symbols,Integers,Real Numbers,Addresses and Instructions 11
1.4.1 Characters and Symbols 11
1.4.2 Integers 12
1.4.3 Real Numbers 14
1.4.4 Hexadecimal and Octal Notations 15
Lesson 1.5 About This Textbook and How to Get The Most Out of It 16
1.5.1 The Lesson 17
1.5.2 The Application Programs 17
Lesson 1.6 Basic Structure 19
Lesson 1.7 Formatting Output 27
Lesson 1.8 More Escape Sequences 30
Lesson 1.9 Basic Debugging 34
Chapter Review 37
Chapter 2 Variables,Arithmetic Expressions and Input/Output 38
Lesson 2.1 Variables:Naming,Declaring,Assigning and Printing Values 38
Lesson 2.2 Arithmetic Operators and Expressions 47
Lesson 2.3 Reading Data from the Keyboard 52
Lesson 2.4 Constant Macros and More About Printing Variable Values 57
Lesson 2.5 Mixed Type Arithmetic,Compound Assignment,Operator Precedence and Type Casting 69
Chapter Review 83
Chapter 3 The Basics of C-Math Functions and Character File Input/Output 84
Lesson 3.1 Math Library Functions 84
Lesson 3.2 Single Character Data 90
Lesson 3.3 Reading Data From a File 105
Lesson 3.4 Writing Output To a File 112
Application Program 3.1 Area Calculation-Compound Operators and Program Development 115
Application Exercises 119
Chapter Review 123
Chapter 4 Beginning Decision Making and Looping 124
Lesson 4.1 If Control Structure and Relational Expressions 125
Lesson 4.2 Simple If-Else Control Structures 130
Lesson 4.3 Nested If-Else Control Structures 135
Lesson 4.4 Logical Expressions 138
Lesson 4.5 Precedence of Logical Operators 142
Lesson 4.6 Switch and If-Else-If Control Structures 147
Lesson 4.7 While Loop(1) 156
Lesson 4.8 While Loop(2) 160
Lesson 4.9 Do-While Loops 162
Lesson 4.10 Simple For Loop 165
Lesson 4.11 Nested For Loops 170
Application Program 4.1 Girder Intersection-If-Else Control Structure 176
Application Program 4.2 Area Calculation-For Loop 179
Application Program 4.3 Temperature Unit Conversions-For Loop 181
Application Program 4.4 Temperature Unit Conversions-Loop and If-Else Control Structure 183
Application Program 4.5 Simulation 185
Application Program 4.6 Engineering Economics-Nested For Loops 187
Application Program 4.7 Solving a Quadratic Equation-If-Else Control Structure(Numerical Method Example) 191
Application Exercises 194
Chapter Review 198
Chapter 5 Functions 199
Lesson 5.1 Functions That Do Not Return a Value 204
Lesson 5.2 Functions That Return Just One Value 216
Lesson 5.3 Scope and Mechanics of Passing Values to Functions 223
Lesson 5.4 Functions That"Return"More Than One Value 230
Lesson 5.5 Mechanics of"Returning"More Than One Value from a Function-Addresses and Pointer Variables 235
Application Program 5.1 Using Functions With Complex Loops and Working with Grids(a Logic Example) 244
Application Program 5.2 Modular Program Design-Area of Parallelogram,Volume of Parallelepiped(Numerical Method Example) 252
Application Exercises 258
Chapter Review 268
Chapter 6 Numeric Arrays 269
Lesson 6.1 Introduction to 1-D Arrays and Printing Array Elements 270
Lesson 6.2 Array Initialisation 277
Lesson 6.3 Basic Array Input/Output 282
Lesson 6.4 Multidimensional Arrays 288
Lesson 6.5 Functions and Arrays 298
Lesson 6.6 Bubble Sort,Exchange Maximum Sort and Exchange Minimum Sort 305
Application Program 6.1 Deriving a 16-bit Adder from Sixteen 1-Bit Adders 313
Application Program 6.2 Mean and Median of Measured Wave Heights(Numerical Method Example) 317
Application Program 6.3 Matrix-Vector Multiplication(Numerical Method Example) 323
Application Program 6.4 Searching and File Compression 327
Application Exercises 332
Chapter Review 339
Chapter 7 Strings and Pointers 340
Lesson 7.1 Declaring,Initialising and Printing Strings and Understanding Memory Arrangement 343
Lesson 7.2 Determining Information About Strings and Characters and Using Printf 353
Lesson 7.3 2-D Character Arrays 361
Lesson 7.4 Reading Strings from The Keyboard and Files 367
Lesson 7.5 Pointer Variables Versus Array Variables 377
Lesson 7.6 Initialising Within a Declaration 386
Lesson 7.7 Passing Strings to User-Defined Functions 393
Lesson 7.8 Standard Character String Functions 400
Lesson 7.9 Pointer Notation Versus Array Notation 416
Lesson 7.10 Dynamic Memory Allocation 427
Program Development Methodology 436
Application Program 7.1 Pipe Fluid Velocity,Checking Input Data and Modular Design 437
Application Program 7.2 Earthquake Anecdotal Report Analysis,String Operations and Dynamic Storage Allocation 449
Application Exercises 464
Chapter Review 469
Chapter 8 Structures and Large Program Design 470
Part Ⅰ:Data Structures 470
Structures in C 471
Lesson 8.1 Structures 472
Lesson 8.2 Structure Members 480
Lesson 8.3 Pointers to Structures 484
Lesson 8.4 Structures and Functions 487
Lesson 8.5 Arrays of Structures 489
Part Ⅱ:Advanced Programming Techniques 492
Lesson 8.6 Functions With One Recursive Call 492
Lesson 8.7 Creating Header Files 500
Lesson 8.8 Use of Multiple Source Code Files and Storage Classes 503
Lesson 8.9 Bitwise Manipulations 507
Application Program 8.1 Sorting-Quicksort Algorithm 521
Chapter Review 534
Chapter 9 An Introduction to C+++(Online Chapter) 535
Appendix A 535
Appendix B 536
Index 537