Part 1 Fundamentals
Chapter 1 Getting started
1.1 Introduction to Programming
Algorithms
From Algorithms to Programs
Program Translation
Exercises 1.1
1.2 Introduction to Modularity
Functions
The main() Function
Exercises 1.2
1.3 The printf() Function
Exercises 1.3
1.4 Programming Style
Comments
Exercises 1.4
1.5 Top-Down Program Development
Modularity and Top-Down Design
Exercises 1.5
1.6 Common Programming Errors
1.7 Chapter Summary
Chapter 2 Data Types, Declarations, and Displays
2.1 Data Types
Integer Values
Floating Point and Double Precision Numbers
Exponential Notation
Character Type
Escape Sequences
Exercises 2.1
2.2 Arithmetic Operators
Integer Division
A Unary Operator (Negation)
Operator Precedence and Associativity
Exercises 2.2
2.3 Displaying Numerical Results
Formatted Output
Format Modifiers
Other Number Bases
Exercises 2.3
2.4 Variables and Declarations
Declaration Statements
Declaration Statements as Definition Statements
Exercises 2.4
2.5 Integer Qualifiers
Determining Storage Size
Exercises 2.5
2.6 Common Programming Errors
2.7 Chapter Summary
2.8 Chapter Supplement: Bits, Bytes, Addresses, and Number Codes
Words and Addresses
Two’s Complement Numbers
Chapter 3 Assignments, Addresses, and Interactive Input
3.1 Assignment
Assignment Operators
Accumulating
Counting
Exercises 3.1
3.2 Addresses
Storing Addresses
Using Addresses
Declaring Pointers
Exercises 3.2
3.3 The scanf() Function
Exercises 3.3
3.4 scanf() with Buffered Input
3.5 Symbolic Constants
Exercises 3.5
3.6 Common Programming Errors
3.7 Chapter Summary
3.8 Chapter Supplement: Introduction to Abstraction
Built-in and Abstract Data Types
Procedural Abstraction
Part 2 Flow of Control
Chapter 4 Selection
4.1 Relational Expressions
Logical Operators
A Numerical Accuracy Problem
Exercises 4.1
4.2 The if-else Statement
Compound Statements
One-Way Selection
Problems Associated with the if-else Statement
Exercises 4.2
4.3 Nested if Statements
The if-else Chain
Exercises 4.3
4.4 The switch Statement
Exercises 4.4
4.5 Common Programming Errors
4.6 Chapter Summary
4.7 Chapter Supplement: Errors, Testing, and Debugging
Compile-Time and Run-Time Errors
Syntax and Logic Errors
Testing and Debugging
Chapter 5 Repetition
5.1 The while Statement
Exercises 5.1
5.2 scanf() within a while Loop
Sentinels
break and continue Statements
The Null Statement
Exercises 5.2
5.3 The for Statement
scanf() within a for Loop
Nested Loops
Exercises 5.3
5.4 The do Statement
Validity Checks
Exercises 5.4
5.5 Common Programming Errors
5.6 Chapter Summary
5.7 Chapter Supplement: Character-Oriented Graphics
Character-at-a-time Display
Exercises 5.7
Part 3 Functions
Chapter 6 Writing Your Own Functions
6.1 Function Definitions and Declarations
Defining a Function
Function Prototypes
Calling a Function
Placement of Statements
Function Stubs
Functions with Empty Parameter Lists
Exercises 6.1
6.2 Standard Library Functions
Input/Output Library Functions
Mathematical Library Functions
Casts
String Library Functions
Miscellaneous Routines
Exercises 6.2
6.3 Variable Scope
Misuse of Global Variables
Exercises 6.3
6.4 Variable Storage Class
Local Variable Storage Classes
Global Variable Storage Classes
Exercises 6.4
6.5 Passing Addresses
Passing, Storing, and Using Addresses
Exercises 6.5
6.6 Common Programming Errors
6.7 Chapter Summary
6.8 Chapter Supplement: Generating Random Numbers
Scaling
Part 4 Complex Data Types
Chapter 7 Arrays
7.1 Single-Dimensional Arrays
Input and Output of Array Values
Exercises 7.1
7.2 Array Initialization
Exercises 7.2
7.3 Passing Arrays
Exercises 7.3
7.4 Two-Dimensional Arrays
Larger Dimensional Arrays
Exercises 7.4
7.5 Common Programming Errors
7.6 Chapter Summary
7.7 Chapter Supplement: Searching and Sorting Methods
Search Algorithms
Linear Search
Return the index value
Binary Search
Big O Notation
Sort Algorithms
The Selection Sort
An Exchange ("Bubble") Sort
Chapter 8 Arrays, Addresses, and Pointers
8.1 Array Names as Pointers
Exercises 8.1
8.2 Pointer Arithmetic
Pointer Initialization
Exercises 8.2
8.3 Passing and Using Array Addresses
Advanced Pointer Notation
Exercises 8.3
8.4 Common Programming Errors
8.5 Chapter Summary
Chapter 9 Character Strings
9.1 String Fundamentals
String Input and Output
String Processing
Character-by-Character Input
Exercises 9.1
9.2 Pointers and Library Functions
Library Functions
Exercises 9.2
9.3 String Definitions and Pointer Arrays
Pointer Arrays
Exercises 9.3
9.4 Formatting Strings
In-Memory String Conversions
Format Strings
Exercises 9.4
9.5 Common Programming Errors
9.6 Chapter Summary
Chapter 10 Structures
10.1 Single Structures
Exercises 10.1
10.2 Arrays of Structures
Exercises 10.2
10.3 Passing and Returning Structures
Returning Structures
Exercises 10.3
10.4 Linked Lists
Exercises 10.4
10.5 Dynamic Memory Allocation
Dynamically Linked Lists
Exercises 10.5
10.6 Unions
Exercises 10.6
10.7 Common Programming Errors
10.8 Chapter Summary
Part 5 Additional Topics
Chapter 11 Data Files
11.1 Declaring, Opening, and Closing Files
Opening a File
Closing a File
Exercises 11.1
11.2 Reading and Writing Files
Standard Device Files
Other Devices
Exercises 11.2
11.3 Random File Access
Exercises 11.3
11.4 Passing and Returning File Names
Exercises 11.4
11.5 Common Programming Errors
11.6 Chapter Summary
11.7 Chapter Supplement: Control Codes
Chapter 12 Additional Capabilities
12.1 Additional Features
The typedef Declaration Statement
The enum Specifier
Casts
Conditional Expressions
The goto Statement
12.2 Bitwise Operations
The AND Operator
The Inclusive OR Operator
The Exclusive OR Operator
The Complement Operator
Different-Sized Data Items
The Shift Operators
12.3 Macros
12.4 Command-Line Arguments
A showad three blind mice
Exercises
12.5 Chapter Summary
Part 6 Introduction to C++
Chapter 13 Introduction to C++
13.1 Object-Based Programming and Abstract Data Types
Abstract Data Types
Comments in C++
Exercises 13.1
13.2 Input and Output in C++
Output in C++
Formatted Output 3
Input in C++
Exercises 13.2
13.3 Function Enhancements in C++
Default Arguments364
Reusing Function Names (Overloading)
Function Templates6
Inline Functions7
Reference Parameters
Passing and Using References
References versus Pointers
Exercises 13.3
13.4 Abstract Data Types in C++ (Classes)
Class Construction
Terminology
Exercises 13.4
13.5 Constructors and Destructors
Calling Constructors
Overloaded and Inline Constructors
Destructors
Arrays of Objects
Exercises 13.5
13.6 An Application
Exercises 13.6
13.7 Common Programming Errors
13.8 Chapter Summary
Chapter 14 Additional Class Capabilities
14.1 Assignment
Copy Constructors
Base/Member Initialization
Exercises 14.1
14.2 Additional Class Features
Class Scope
Static Class Members
The this Pointer
Friend Functions
Exercises 14.2
14.3 Operator Functions
The Assignment Operator Revisited
Exercises 14.3
14.4 Data Type Conversions
Built-in to Built-in Conversion
Built-in to User-defined (Class) Conversion
User-defined (Class) to Built-in Conversion
User-defined (Class) to User-defined (Class) Conversion
Exercises 14.4
14.5 Class Inheritance
Inheritance
Access Specifications
An Example
Polymorphism
Exercises 14.5
14.6 Common Programming Errors
14.7 Chapter Summary
Appendix A Operator Precedence Table
Appendix B ASCII Character Codes
Appendix C Input, Output, and Standard Error Redirection
Appendix D The Standard C Library
Appendix E The Standard Template Library (C++)
Appendix F Program Entry, Compilation, and Execution
Appendix G Using Visual C++ Version 6.0
Appendix H Using C++ Builder
Appendix I Solutions