Author(s): Tony Gaddis
Edition: 6
Contents at a Glance
Contents
Preface
Chapter 1 - Introduction to Computers and Programming
Chapter 2 - Introduction to C++
2.1 The Parts of a C++ Program
2.2 The cout Object
2.3 The #include Directive
2.4 Variables and Literals
Sometimes a Number Isn't a Number
Literals
2.5 Identifiers
Legal Identifiers
2.6 Integer Data Types
Integer and Long Integer Literals
If You Plan to Continue in Computer Science: Hexadecimal and Octal Literals
2.7 The char Data Type
Character Literals
2.8 Floating-Point Data Types
Floating Point Literals
Assigning Floating-Point Values to Integer Variables
2.9 The bool Data Type
2.10 Determining the Size of a Data Type
2.11 Variable Assignments and Initialization
2.12 Scope
2.13 Arithmetic Operators
2.14 Comments
Single-line Comments
Multi-Line Comments
2.15 Focus on Software Engineering: Programming Style
2.16 If You Plan to Continue in Computer Science:Standard and Prestandard C++
Older Style Header Files
Absence of using namespace std;
An Older Style Program
Review Questions and Exercises
Short Answer
Multiple Choice
True or False
Algorithm Workbench
Find the Error
Programming Challenges
Serendipity Booksellers Software Development ProjectPart2: A Problem-Solving Exercise
Chapter 3 - Expressions and Interactivity
Chapter 4 - Making Decisions
4.1 Relational Operators
The Value of a Relationship
What Is Truth?
4.2 The if Statement
Be Careful with Semicolons
Programming Style and the if Statement
Comparing Floating-Point Numbers
And Now Back to Truth
Don't Confuse == With =
4.3 Flags
Integer Flags
4.4Expanding the if Statement
Don't forget the Braces!
4.5 The if/else Statement
4.6 Nested if Statements
Programming Style and Nested Decision Structures
Testing a Series of Conditions
4.7 The if/else if Statement
Using the Trailing else To Catch Errors
The if/else i f Statement Compared to a Nested Decision Structure
4.8 Menus
4.9 Logical Operators
The && Operator
The || Operator
The ! Operator
Precedence and Associativity of Logical Operators
4.10 Checking Numeric Ranges with Logical Operators
4.11 Focus on Software Engineering: Validating User Input
4.12 More About Variable Definitions and Scope
Variables with the Same Name
4.13 Comparing Strings
The strcmp Function
Using ! with strcmp
Sorting Strings
4.14 The Conditional Operator
Using the Value of a Conditional Expression
4.15 The switch Statement
Using switch in Menu Systems
4.16 Testing for File Open Errors
Review Questions and Exercises
Short Answer
Fill-in-the-Blank
Algorithm Workbench
True or False
Find the Errors
Programming Challenges
Serendipity Booksellers Software Development ProJect Part4: A Problem-Solving Exercise
Chapter 5 - Looping
5.1 The Increment and Decrement Operators
5.2 Introduction to Loops: The while Loop
5.3 Using the while Loop for Input Validation
5.4 Counters
5.5 The do-while Loop
5.6 The for Loop
The for Loop Is a Pretest Loop
Omitting the for Loop's Expressions
Avoid Modifying the Counter Variablein the Body of the for Loop
5.7 Keeping a Running Total
5.8 Sentinels
Figure 5-12 Logic for calculating a running total
5.9 Using a Loop to Read Data from a File
5.10 Focus on Software Engineering:Deciding Which Loop to Use
5.11 Nested Loops
5.12 Breaking Out of a Loop
Using break in a Nested Loop
5.13 The continue Statement
Review Questions and Exercises
Short Answer
Fill-in-the-Blank
Algorithm Workbench
True or False
Find the Errors
Programming Challenges
Serendipity Booksellers Software Development ProjectPartS: A Problem-Solving Exercise
Chapter 6 - Functions
6.1 Focus on Software Engineering: Modular Programming
6.2 Defining and Calling Functions
void Functions
Calling a Function
6.3 Function Prototypes
6.4 Sending Data into a Function
6.5 Passing Data by Value
6.6 Focus on Software Engineering: Using Functionsin a Menu-Driven Program
6.7 The return Statement
6.8 Returning a Value from a Function
Defining a Value-Returning Function
Calling a Value-Returning Function
6.9 Returning a Boolean Value
6.10 Local and Global Variables
Local Variables
Local Variable Lifetime
Initializing Local Variables with Parameter Values
Global Variables and Global Constants
Local and Global Variables with the Same Name
6.11 Static Local Variables
6.12 Default Arguments
6.13 Using Reference Variables as Parameters
6.14 Overloading Functions
6.15 The exit() Function
6.16 Stubs and Drivers
Review Questions and Exercises
Programming Challenges
Serendipity Booksellers Software Development ProjectPart6: A Problem-Solving Exercise
Chapter 7 - Arrays
7.1 Arrays Hold Multiple Values
Memory Requirements of Arrays
7.6 Focus on Software Engineering:Using Parallel Arrays
7.7 Arrays as Function Arguments
Some Useful Array Functions
7.8 Two-Dimensional Arrays
Passing Two-Dimensional Arrays to Functions
Summing All the Elements of a Two-Dlmemlonal Array
Summing the Rows of a Two-Dimensional Array
Summing the Columns of a Two-Dimensional Array
7.9 Arrays of Strings
Chapter 8 - Searching and Sorting Arrays
Chapter 9 - Pointers
Chapter 10 - Characters, Strings, and the string Class
Chapter 11 - Structured Data
Chapter 12 - Advanced File Operations
Chapter 13 - Introduction to Classes