A Modern Approach
K. N. King (Ph.D., University of California, Berkeley) is Associate Professor of Computer Science at Georgia State University. He is the author of Modula-2: A Complete Guide and Java Programming: From the Beginning.
1. Introducing C 1.1 History of C Origins Standardization C++ 1.2 Strengths and Weaknesses of C Strengths Weaknesses Effective Use of C 2. C Fundamentals 2.1 Writing a Simple Program PROGRAM: Printing a Pun Compiling and Linking 2.2 The General Form of a Simple Program Directives Functions Statements Printing Strings 2.3 Comments 2.4 Variables and Assignment Types Declarations Assignment Printing the Value of a Variable PROGRAM: Computing the Dimensional Weight of a Box Initialization Printing Expressions 2.5 Reading Input PROGRAM: Computing the Dimensional Weight of a Box (Revisited) 2.6 Defining Constants PROGRAM: Converting from Fahrenheit to Celsius 2.7 Identifiers Keywords 2.8 Layout of a C Program 3. Formatted Input/Output 3.1 The printf Function Conversion Specifications PROGRAM: Using printf to Format Numbers Escape Sequences 3.2 The scanf Function How scanf Works Ordinary Characters in Format Strings Confusing printf with scanf PROGRAM: Computing the Value of Stock Holdings 4. Expressions 4.1 Arithmetic Operators Operator Precedence and Associativity PROGRAM: Computing a UPC Check Digit 4.2 Assignment Operators Simple Assignment Lvalues Compound Assignment 4.3 Increment and Decrement Operators 4.4 Expression Evaluation Order of Subexpression Evaluation 4.5 Expression Statements 5 Selection Statements 5.1 Logical Expressions Relational Operators Equality Operators Logical Operators 5.2 The if Statement Compound Statements The else Clause Cascaded if Statements PROGRAM: Calculating a Broker\'s Commission The \'Dangling else\' Problem Conditional Expressions Boolean Values 5.3 The switch Statement The Role of the break Statement PROGRAM: Printing a Date in Legal Form 6. Loops 6.1 The while Statement Infinite Loops PROGRAM: Printing a Table of Squares PROGRAM: Summing a Series of Numbers 6.2 The do Statement PROGRAM: Calculating the Number of Digits in an Integer 6.3 The for Statement for Statement Idioms Omitting Expressions in a for Statement The Comma Operator PROGRAM: Printing a Table of Squares (Revisited) 6.4 Exiting from a Loop The break Statement The continue Statement The goto Statement PROGRAM: Balancing a Checkbook 6.5 The Null Statement 7. Basic Types 7.1 Integer Types Integer Constants Reading and Writing Integers PROGRAM: Summing a Series of Numbers (Revisited) 7.2 Floating Types Floating Constants Reading and Writing Floating-Point Numbers 7.3 Character Types Escape Sequences Character-Handling Functions Reading and Writing Characters PROGRAM: Determining the Length of a Message 7.4 The sizeof Operator 7.5 Type Conversion The Usual Arithmetic Conversions Conversion During Assignment Casting 7.6 Type Definitions 8. Arrays 8.1 One-Dimensional Arrays Array Subscripting PROGRAM: Reversing a Series of Numbers Array Initialization PROGRAM: Checking a Number for Repeated Digits Using the sizeof Operator with Arrays PROGRAM: Computing Interest 8.2 Multidimensional Arrays Initializing a Multidimensional Array Constant Arrays PROGRAM: Dealing a Hand of Cards 9. Functions 9.1 Defining and Calling Functions PROGRAM: Computing Averages PROGRAM: Printing a Countdown PROGRAM: Printing a Pun (Revisited) Function Definitions Function Calls PROGRAM: Testing Whether a Number Is Prime 9.2 Function Declarations 9.3 Arguments Argument Conversions Array Arguments 9.4 The return Statement The exit Function 9.6 Recursive Functions The Quicksort Algorithm PROGRAM: Quicksort 10. Program Organization 10.1 Local Variables Parameters 10.2 External Variables Example: Using External Variables to Implement a Stack Pros and Cons of External Variables PROGRAM: Guessing a Number 10.3 Blocks 10.4 Scope 10.5 Organizing a C Program PROGRAM: Classifying a Poker Hand 11. Pointers 11.1 Pointer Variables Declaring Pointer Variables 11.2 The Address and