COVER
TITLE PAGE
COPYRIGHT
PREFACE
A WALKTHOUGH OF THE LEARNING AIDS
ACKNOWLEDGMENTS
CONTENTS
SPECIAL FEATURES
CHAPTER 1 INTRODUCTION
1.1 What is Programming
1.2 The Anatomy of a Computer
1.3 Machine Code and Programming Languages
1.4 Becoming Familiar with Your Programming Environment
1.5 Analyzing Your First Program
1.6 Errors
1.7 Problem Solving: Algorithm Design
CHAPTER SUMMARY
REVIEW EXERCISES
PROGRAMMING EXERCISES
ANSWERS TO SELF - CHECK QUESTIONS
CHAPTER 2 FUNDAMENTAL DATA TYPES
2.1 Variables
2.1.1 Variable Definitions
2.1.2 Number Types
2.1.3 Variable Names
2.1.4 The Assignment Statement
2.1.5 Constants
2.1.6 Comments
2.2 Arithmetic
2.2.1 Arithmetic Operators
2.2.2 Increment and Decrement
2.2.3 Integer Division and Remainder
2.2.4 Converting Floating-Point Numbers to Integers
2.2.5 Powers and Roots
2.3 Input and Output
2.3.1 Input
2.3.2 Formatted Output
2.4 Problem Solving: First Do It By Hand
2.5 Strings
2.5.1 The String Type
2.5.2 Concatenation
2.5.3 String Input
2.5.4 String Functions
CHAPTER SUMMARY
REVIEW EXERCISES
PROGRAMMING EXERCISES
ANSWERS TO SELF - CHECK QUESTIONS
CHAPTER 3 DECISIONS
3.1 The if Statement
3.2 Comparing Numbers and Strings
3.3 Multiple Alternatives
3.4 Nested Branches
3.5 Problem Solving: Flowcharts
3.6 Problem Solving: Test Cases
3.7 Boolean Variables and Operators
3.8 Application: Input Validation
CHAPTER SUMMARY
REVIEW EXERCISES
PROGRAMMING EXERCISES
ANSWERS TO SELF - CHECK QUESTIONS
CHAPTER 4 LOOPS
4.1 The while Loop
4.2 Problem Solving: Hand-Tracing
4.3 The for Loop
4.4 The do Loop
4.5 Processing Input
4.6 Problem Solving: Storyboards
4.7 Common Loop Algorithms
4.7.1 Sum and Average Value
4.7.2 Counting Matches
4.7.3 Finding the First Match
4.7.4 Maximum and Minimum
4.7.5 Comparing Adjacent Values
4.8 Nested Loops
4.9 Random Numbers and Simulations
4.9.1 Generating Random Numbers
4.9.2 Simulating Die Tosses
4.9.3 The Monte Carlo Method
CHAPTER SUMMARY
REVIEW EXERCISES
PROGRAMMING EXERCISES
ANSWERS TO SELF - CHECK QUESTIONS
CHAPTER 5 FUNCTIONS
5.1 Functions as Black Boxes
5.2 Implementing Functions
5.3 Parameter Passing
5.4 Return Values
5.5 Functions Without Return Values
5.6 Problem Solving: Reusable Functions
5.7 Problem Solving: Stepwise Refinement
5.8 Variable Scope and Global Variables
5.9 Reference Parameters
5.10 Recursive Functions (Optional)
CHAPTER SUMMARY
REVIEW EXERCISES
PROGRAMMING EXERCISES
ANSWERS TO SELF - CHECK QUESTIONS
CHAPTER 6 ARRAYS AND VECTORS
6.1 Arrays
6.1.1 Defining Arrays
6.1.2 Accessing Array Elements
6.1.3 Partially Filled Arrays
6.2 Common Array Algorithms
6.2.1 Filling
6.2.2 Copying
6.2.3 Sum and Average Value
6.2.4 Maximum and Minimum
6.2.5 Element Separators
6.2.6 linear Search
6.2.7 Removing an Element
6.2.8 Inserting an Element
6.2.9 Swapping Elements
6.2.10 Reading Input
6.3 Arrays And Functions
6.4 Problem Solving: Adapting Algorithms
6.5 Problem Solving: Discovering Algorithms by Manipulating Physical Objects
6.6 Two-Dimensional Arrays
6.6.1 Defining Two-Dimensional Arrays
6.6.2 Accessing Elements
6.6.3 Computing Row and Column Totals
6.6.4 Two-Dimensional Array Parameters
6.7 Vectors
6.7.1 Defining Vectors
6.7.2 Growing and Shrinking Vectors
6.7.3 Vectors and Functions
6.7.4 Vector Algorithms
CHAPTER SUMMARY
REVIEW EXERCISES
PROGRAMMING EXERCISES
ANSWERS TO SELF - CHECK QUESTIONS
CHAPTER 7 POINTERS
7.1 Defining and Using Pointers
7.1.1 Defining Pointers
7.1.2 Accessing Variables Through Pointers
7.1.3 Initializing Pointers
7.2 Arrays and Pointers
7.2.1 Arrays as Pointers
7.2.2 Pointer Arithmetic
7.2.3 Array Parameter Variables are Pointers
7.3 C and C++ Strings
7.3.1 The Char Type
7.3.2 C Strings
7.3.3 Character Arrays
7.3.4 Converting Between C and C++ Strings
7.3.5 C++ Strings and The [] Operator
7.4 Dynamic Memory Allocation
7.5 Arrays and Vectors of Pointers
7.6 Problem Solving: Draw a Picture
7.7 Structures and Pointers (Optional)
7.7.1 Structures
7.7.2 Pointers to Structures
7.7.3 Structures with Pointer Members
CHAPTER SUMMARY
REVIEW EXERCISES
PROGRAMMING EXERCISES
ANSWERS TO SELF - CHECK QUESTIONS
CHAPTER 8 STREAMS
8.1 Reading and Writing Text Files
8.1.1 Opening a Stream
8.1.2 Reading from a File
8.1.3 Writing to a File
8.1.4 A File Processing Example
8.2 Reading Text Input
8.2.1 Reading Words
8.2.2 Reading Characters
8.2.3 Reading lines
8.3 Writing Text Output
8.4 String Streams
8.5 Command Line Arguments
8.6 Random Access and Binary Files
8.6.1 Random Access
8.6.2 Binary Files
8.6.3 Processing Image Files
CHAPTER SUMMARY
REVIEW EXERCISES
PROGRAMMING EXERCISES
ANSWERS TO SELF - CHECK QUESTIONS
CHAPTER 9 CLASSES
9.1 Object-Oriented Programming
9.2 Specifying the Public Interface of a Class
9.3 Data Members
9.4 Member Functions
9.4.1 Implementing Member Functions
9.4.2 Implicit and Explicit Parameters
9.4.3 Calling a Member Function from a Member Function
9.5 Constructors
9.6 Problem Solving: Tracing Objects
9.7 Problem Solving: Discovering Classes
9.8 Separate Compilation
9.9 Pointers to Objects
9.9.1 Dynamically allocating objects
9.9.2 The -> Operator
9.9.3 The This Pointer
CHAPTER SUMMARY
REVIEW EXERCISES
PROGRAMMING EXERCISES
ANSWERS TO SELF - CHECK QUESTIONS
CHAPTER 10 INHERITANCE
10.1 Inheritance Hierarchies
10.2 Implementing Derived Classes
10.3 Overriding Member Functions
10.4 Virtual Functions and Polymorphism
10.4.1 The Slicing Problem
10.4.2 Pointers to Base and Derived Classes
10.4.3 Virtual Functions
10.4.4 Polymorphism
CHAPTER SUMMARY
REVIEW EXERCISES
PROGRAMMING EXERCISES
ANSWERS TO SELF - CHECK QUESTIONS
APPENDICES
APPENDIX A: C++ LANGUAGE CODING GUIDELINES
APPENDIX B: RESERVED WORD SUMMARY
APPENDIX C: OPERATOR SUMMARY
APPENDIX D: CHARACTER CODES
APPENDIX E: C++ LIBRARY SUMMARY
GLOSSARY
INDEX
CREDITS