Contents
Chapter 1 Introduction to Computers and Programming
1.1 Overview of Computers and Programming
1.2 Historical Developments
1.3 Computer Hardware
1.3.1 Input and Output (I/O) Devices
1.3.2 Random-Access Memory (RAM)
1.3.3 Central Processing Unit (CPU)
1.3.4 Storage Devices
1.3.5 Motherboard
1.4 Computer Software
1.4.1 Application Software
1.4.2 System Software
1.5 Embedded Systems
1.6 Programming Paradigms
1.7 Programming Languages
1.7.1 The C Programming Language
1.7.2 The C++ Programming Language
1.8 Data Hierarchy
1.9 Numbering Systems
1.9.1 Counting
1.9.2 Converting from a Base to Base 10
1.9.3 Converting from Base 10 to a Different Base
1.10 Summary
1.11 Answers to Selected Chapter Exercises
Chapter 2 Program Design and Development
2.1 Procedural Programming
2.2 Problem-Solving Overview
2.2.1 Development Process
2.3 Algorithm Representation
2.3.1 Flowchart
2.3.2 Pseudocode
2.4 Algorithm Development
2.4.1 Value of Algorithm Development
2.4.2 Stepwise Refinement
2.5 Compilation Process
2.5.1 Editor
2.5.2 Preprocessor
2.5.3 Language Translator
2.5.4 Linker
2.6 Program Development in Microsoft Visual Studio
2.6.1 Using an Integrated Development Environment (IDE)
2.7 Running the Program
2.8 Errors
2.8.1 Syntax Error
2.8.2 Linker Error
2.8.3 Run-Time Error
2.8.4 Logic Error
2.9 Desk Checking
2.10 Using Visual Studio (VS)
2.10.1 Getting Started
2.11 Debugging
2.12 Problem Solving Applied
2.13 Summary
2.14 Debugging Exercise
2.15 Programming Exercises
2.16 Team Programming Exercise
2.17 Answers to Chapter Exercises
Chapter 3 Getting Started with C++
3.1 C++ Basics
3.2 Whitespace
3.3 Comments
3.4 The main Function
3.5 The #include Preprocessor Directive
3.5.1 Namespaces
3.6 Problem Solving Applied
3.7 C—The Differences
3.8 Summary
3.9 Debugging Exercise
3.10 Programming Exercises
3.11 Team Programming Exercise
3.12 Answers to Chapter Exercises
Chapter 4 Literals, Variables, and Constants
4.1 Literals
4.2 Character Escape Sequences
4.3 Variable Declarations
4.3.1 Variable's Initial Value
4.3.2 Initialization
4.3.3 Data Types
4.3.4 The sizeof Operator
4.3.5 Numeric Literal Suffixes
4.3.6 Naming Rules
4.4 ASCII Characters
4.5 Constants
4.6 const Versus #define
4.7 Bringing It All Together
4.8 Variable Declarations in Pseudocode
4.9 Problem Solving Applied
4.10 C—The Differences
4.11 Summary
4.12 Debugging Exercise
4.13 Programming Exercises
4.14 Team Programming Exercise
4.15 Answers to Chapter Exercises
Chapter 5 Input and Output Streams
5.1 Input and Output Streams
5.1.1 Namespaces and I/O Streams
5.1.2 The cout Statement
5.1.3 The cin Statement
5.2 The end1 Manipulator
5.2.1 The endl Manipulator Versus ‘
’
5.3 Input and Output Buffers
5.4 Formatting the Output Stream
5.4.1 The .width Member Function and setw Manipulator
5.4.2 The .precision Member Function and setprecision Manipulator
5.4.3 The . setf Member Function
5.4.4 The .flush Member Function and flush Manipulator
5.5 Debugging
5.5.1 Step Into, Step Over, and Step Out
5.5.2 Run to Cursor
5.5.3 Breakpoints
5.5.4 Watches
5.5.5 Importance of Debugging
5.6 Problem Solving Applied
5.7 C—The Differences
5.7.1 The printf Function
5.7.2 Formatting the printf Statement
5.7.3 Flushing the Output Buffer
5.7.4 The scan f Function
5.7.5 The getch Function
5.8 Summary
5.9 Debugging Exercise
5.10 Programming Exercises
5.11 Team Programming Exercises
5.12 Answers to Chapter Exercises
Chapter 6 Mathematical Operations
6.1 Mathematical Expressions
6.2 Assignment Operator (=)
6.3 Standard Arithmetic Operators (+, -, *, /, %)
6.4 Increment and Decrement Operators (++, --)
6.5 Compound Assignment Operators (+=,-=, *=, /=, %=)
6.6 Accumulators Versus Counters
6.7 Order of Precedence
6.8 Mathematical Functions
6.8.1 The pow Function
6.8.2 The sqrt Function
6.8.3 The abs Function
6.9 Type Casting
6.10 Problem Solving Applied
6.11 C—The Differences
6.12 Summary
6.13 Debugging Exercise
6.14 Programming Exercises
6.15 Team Programming Exercise
6.16 Answers to Chapter Exercises
Chapter 7 Conditional Statements
7.1 Conditional Expressions
7.1.1 Relational Operators
7.1.2 Logical Operators
7.2 The if Statement
7.2.1 The else Statement
7.2.2 The else if Statement
7.3 Variable Scope
7.4 The switch Statement
7.5 Conditional Operator
7.6 Problem Solving Applied
7.7 C—The Differences
7.8 Summary
7.9 Debugging Exercise
7.10 Programming Exercises
7.11 Team Programming Exercise
7.12 Answers to Chapter Exercises
Chapter 8 Repetition Statements
8.1 General Repetition Concepts
8.2 The while Loop
8.3 The do-while Loop
8.4 The for Loop
8.4.1 Nested for Loops
8.5 Breakpoints and Loops
8.6 Problem Solving Applied
8.7 C—The Differences
8.8 Summary
8.9 Debugging Exercise
8.10 Programming Exercises
8.11 Team Programming Exercise
8.12 Answers to Chapter Exercises
Chapter 9 Functions
9.1 What Are Functions?
9.1.1 Advantages and Disadvantages of Functions
9.1.2 What about main
9.2 Function Components
9.2.1 Function Declaration
9.2.2 Function Definition
9.2.3 Function Call
9.3 Return
9.4 Passing Parameters
9.4.1 Formal and Actual Parameters
9.4.2 Scope
9.4.3 Passing by Value
9.4.4 Passing by Reference
9.5 Default Arguments
9.6 Putting It All Together
9.7 Debugging—Call Stack
9.8 More Predefined Functions
9.8.1 Character Case
9.8.2 The “is” Functions
9.9 Structure Charts
9.10 Problem Solving Applied
9.11 C—The Differences
9.12 Summary
9.13 Debugging Exercise
9.14 Programming Exercises
9.15 Team Programming Exercise
9.16 Answers to Chapter Exercises
Chapter 10 Arrays and cStrings
10.1 What Are Arrays?
10.1.1 Advantages and Disadvantages of Arrays
10.2 Declaring Arrays
10.3 Using Arrays
10.4 Initialization
10.5 Array Manipulation
10.6 Passing Arrays to Functions
10.7 Special Case: cStrings
10.7.1 cString Initialization
10.7.2 I/O with cStrings
10.7.3 cStrings and the “address of” Operator
10.8 cString Functions
10.8.1 Copying
10.8.2 Appending
10.8.3 Comparing
10.8.4 Finding the Length
10.8.5 Changing the Case
10.8.6 Reversing
10.8.7 Converting cStrings to Numbers
10.8.8 Converting Numbers to cStrings
10.8.9 Summary of cString Functions
10.9 cString Function Standards
10.10 Multidimensional Arrays
10.10.1 Declaration
10.10.2 Initialization
10.10.3 Multidimensional Array I/O
10.10.4 Passing Multidimensional Arrays
10.11 Parallel Arrays
10.12 Problem Solving Applied
10.13 C—The Differences
10.14 Summary
10.15 Debugging Exercise
10.16 Programming Exercises
10.17 Team Programming Exercise
10.18 Answers to Chapter Exercises
Chapter 11 File I/O and Data Manipulation
11.1 Data Files
11.2 File Streams
11.3 Opening Files
11.4 Checking for Successful Opening
11.5 Closing Files
11.6 Writing to Files
11.7 Reading from Files
11.8 Searching
11.9 Sorting
11.10 Problem Solving Applied
11.11 C—The Differences
11.11.1 File Pointer
11.11.2 Opening Files
11.11.3 Checking for a Successful Open
11.11.4 Closing Files
11.11.5 Writing to a File
11.11.6 Reading from a File
11.12 Summary
11.13 Debugging Exercise
11.14 Programming Exercises
11.15 Team Programming Exercise
11.16 Answers to Chapter Exercises
Chapter 12 Pointers and Dynamic Memory Allocation
12.1 Definition
12.2 Declaration
12.3 Advanced Pointer Declarations
12.4 Indirection Operator
12.5 Passing by Pointer
12.6 Pointer Arithmetic
12.7 Pointers Applied
12.8 More cString Functions
12.8.1 The strtok Function
12.8.2 The strstr Function
12.8.3 The strchr Function
12.8.4 The memset Function
12.9 Dynamic Memory Allocation
12.9.1 The new Operator
12.9.2 The delete Operator
12.10 Passing Pointers by Reference
12.11 Pointers and Strings
12.12 Ragged Arrays
12.13 Dynamic Two-Dimensional Arrays
12.14 Testing for Memory Leaks
12.15 Function Pointers
12.15.1 Declaration
12.15.2 Retrieving a Function's Address
12.15.3 Indirectly Calling a Function
12.15.4 Uses of Function Pointers
12.16 Problem Solving Applied
12.17 C—The Differences
12.17.1 Dynamic Memory Allocation
12.17.2 Dynamic Memory Deallocation
12.17.3 Memory Leak Detection
12.18 Summary
12.19 Debugging Exercise
12.20 Programming Exercises
12.21 Team Programming Exercise
12.22 Answers to Chapter Exercises
Chapter 13 User-Defined Types
13.1 The typedef Statement
13.2 Enumerated Data Types
13.3 Structures
13.3.1 Nested Structures
13.3.2 Structure Variables
13.3.3 Accessing the Data Members
13.3.4 Structure Variable Manipulation
13.3.5 Shallow Copy Versus Deep Copy
13.4 Unions
13.5 Problem Solving Applied
13.6 C—The Differences
13.7 Summary
13.8 Debugging Exercise
13.9 Programming Exercise
13.10 Team Programming Exercise
13.11 Answers to Chapter Exercises
Chapter 14 Introduction to Object-Oriented Programming
14.1 History of Object-Oriented Programming
14.2 Key Concepts of Object-Oriented Programming
14.2.1 Encapsulation
14.2.2 Interface Versus Implementation
14.2.3 Inheritance
14.2.4 Polymorphism
14.3 Advantages and Disadvantages
14.3.1 Models Real Life
14.3.2 Self-Contained
14.3.3 Code Reuse
14.3.4 OOP Overhead
14.4 String Class
14.4.1 Instantiation and Initialization
14.4.2 Reading and Writing Strings
14.4.3 Other String Features
14.5 UML Introduction
14.5.1 UML Overview
14.5.2 Class Diagrams
14.6 Problem Solving Applied
14.7 C—The Differences
14.8 Summary
14.9 Answers to Chapter Exercises
Chapter 15 Introduction to Classes
15.1 Classes
15.1.1 Definition Syntax
15.1.2 Access Specifiers
15.1.3 Data Members
15.1.4 Member Functions
15.1.5 Setters and Getters
15.2 Instantiation
15.3 Manager Functions
15.3.1 Constructor
15.3.2 Destructor
15.4 Implementation Hiding
15.4.1 #include “header.h”
15.5 Conditional Compilation
15.5.1 #ifndef
15.5.2 #pragma once
15.6 Base Member Initialization
15.7 Function Overloading
15.7.1 Name Mangling
15.8 Passing By Const-ref
15.8.1 Const Methods
15.9 Problem Solving Applied
15.10 C—The Differences
15.11 Summary
15.12 Debugging Exercise
15.13 Programming Exercises
15.14 Team Programming Exercise
15.15 Answers to Chapter Exercises
Chapter 16 Miscellaneous Topics
16.1 Storage Classes
16.1.1 Static
16.1.2 Extern
16.2 Command-Line Arguments
16.3 Conditional Compilation
16.4 Macros
16.4.1 Advantages and Disadvantages
16.5 Bitwise Operations
16.5.1 Bitwise Operators
16.5.2 Bit Fields
16.5.3 Masking
16.6 Recursion
16.7 Summary
16.8 Programming Exercises
16.9 Answers to Chapter Exercises
Chapter 17 Binary and Random Access Files
17.1 Text Files Versus Binary Files
17.1.1 Advantages and Disadvantages of Binary Files
17.2 Opening and Closing Binary Files
17.3 Binary File I/O
17.4 Sequential Files Versus Random Access Files
17.4.1 Determining Current FPM Location
17.4.2 Moving the FPM
17.5 C—The Differences
17.5.1 File Modes
17.5.2 Binary File I/O with C
17.5.3 Random Access Functions
17.6 Summary
17.7 Programming Exercise
17.8 Answers to Chapter Exercises
Chapter 18 Introduction to Linked Lists
18.1 Data Structures
18.2 Linked Lists
18.2.1 List Implementation Options
18.2.2 Node Structure
18.2.3 Head Pointer
18.2.4 Creating a New Node
18.3 Prepending a Node
18.4 Appending a Node
18.5 Inserting a Node into an Ordered List
18.6 Traversing the List
18.7 Deleting Nodes
18.7.1 Deleting All Nodes
18.7.2 Deleting a Specific Node from an Ordered List
18.8 Arrays Versus Linked Lists
18.9 Problem Solving Applied
18.10 C—The Differences
18.11 Summary
18.12 Debugging Exercise
18.13 Programming Exercises
18.14 Team Programming Exercise
18.15 Answers to Chapter Exercises
Appendix A ASCII Chart
Glossary
Index