did-you-know? rent-now

Amazon no longer offers textbook rentals. We do!

did-you-know? rent-now

Amazon no longer offers textbook rentals. We do!

We're the #1 textbook rental company. Let us show you why.

9781418836399

C++ Programming

by
  • ISBN13:

    9781418836399

  • ISBN10:

    1418836397

  • Edition: 3rd
  • Format: Paperback
  • Copyright: 2006-02-09
  • Publisher: Cengage Learning Ptr
  • View Upgraded Edition
  • Purchase Benefits
  • Free Shipping Icon Free Shipping On Orders Over $35!
    Your order must be $35 or more to qualify for free economy shipping. Bulk sales, PO's, Marketplace items, eBooks and apparel do not qualify for this offer.
  • eCampus.com Logo Get Rewarded for Ordering Your Textbooks! Enroll Now
List Price: $172.95

Summary

C++ Programming: From Problem Analysis to Program Design, Third Edition is the ground-breaking, definitive text for the CS1 course. Best-selling author D.S. Malik employs a student-focused approach, using complete programming examples to teach introductory programming concepts. This third edition has been enhanced to further demonstrate the use of OOD methodology, to introduce sorting algorithms (bubble sort and insertion sort), and to present additional material on abstract classes. In addition, the exercise sets at the end of each chapter have been expanded, and now contain several calculus and engineering-related exercises. Finally, all programs have been written, compiled, and quality-assurance tested with Microsoft Visual C++ .NET, available as an optional compiler with this text.

Table of Contents

Preface xxvii
An Overview of Computers and Programming Languages
1(28)
Introduction
2(1)
A Brief Overview of the History of Computers
2(1)
Elements of a Computer System
3(3)
Hardware
3(1)
Central Processing Unit
3(1)
Main Memory
4(1)
Secondary Storage
5(1)
Input/Output Devices
5(1)
Software
6(1)
The Language of a Computer
6(2)
The Evolution of Programming Languages
8(1)
A C++ Program
9(3)
Processing a C++ Program
12(2)
Programming with the Problem Analysis--Coding--Execution Cycle
14(8)
Programming Methodologies
22(2)
Structured Programming
22(1)
Object-Oriented Programming
22(2)
ANSI/ISO Standard C++
24(1)
Quick Review
24(2)
Exercises
26(3)
Basic Elements of C++
29(86)
The Basics of a C++ Program
30(4)
Special Symbols
32(1)
Word Symbols
32(1)
Identifiers
32(2)
Data Types
34(5)
Simple Data Types
34(3)
Floating-Point Data Types
37(2)
Arithmetic Operators and Operator Precedence
39(5)
Order of Precedence
43(1)
Expressions
44(3)
Mixed Expressions
45(2)
Type Conversion (Casting)
47(4)
string Type
50(1)
Input
51(17)
Allocating Memory with Constants and Variables
51(3)
Putting Data into Variables
54(1)
Assignment Statement
54(2)
Saving and Using the Value of an Expression
56(1)
Declaring and Initializing Variables
57(1)
Input (Read) Statement
58(4)
Variable Initialization
62(6)
Increment and Decrement Operators
68(2)
Output
70(8)
Preprocessor Directives
78(2)
namespace and Using cin and cout in a Program
79(1)
Using the string Data Type in a Program
79(1)
Creating a C++ Program
80(4)
Program Style and Form
84(5)
Syntax
84(1)
Use of Blanks
85(1)
Use of Semicolons, Brackets, and Commas
85(1)
Semantics
85(1)
Naming Identifiers
85(1)
Prompt Lines
86(1)
Documentation
87(1)
Comments
87(1)
Form and Style
87(2)
More on Assignment Statements
89(2)
Programming Example: Convert Length
91(4)
Programming Example: Make Change
95(3)
Quick Review
98(2)
Exercises
100(9)
Programming Exercises
109(6)
Input/Output
115(52)
I/O Streams and Standard I/O Devices
116(7)
cin and the Extraction Operator >>
117(6)
Using Predefined Functions in a Program
123(8)
cin and the get Function
125(1)
cin and the ignore Function
126(2)
The putback and peek Functions
128(2)
The Dot Notation Between I/O Stream Variables and I/O Functions: A Precaution
130(1)
Input Failure
131(4)
The clear Function
133(2)
Output and Formatting Output
135(6)
setprecision Manipulator
135(1)
fixed Manipulator
136(1)
showpoint Manipulator
136(2)
setw
138(3)
flush Manipulator
141(1)
Additional Output Formatting Tools
141(5)
setfill Manipulator
142(1)
left and right Manipulators
143(3)
Input/Output and the string Type
146(1)
File Input/Output
147(3)
Programming Example: Movie Ticket Sale and Donation to Charity
150(6)
Programming Example: Student Grade
156(3)
Quick Review
159(2)
Exercises
161(3)
Programming Exercises
164(3)
Control Structures I (Selection)
167(64)
Control Structures
168(1)
Relational Operators
169(6)
Relational Operators and Simple Data Types
171(2)
Relational Operators and the string Type
173(2)
Logical (Boolean) Operators and Logical Expressions
175(9)
Order of Precedence
177(4)
Short-Circuit Evaluation
181(1)
int Data Type and Logical (Boolean) Expressions
182(1)
bool Data Type and Logical (Boolean) Expressions
183(1)
Selection: if and if...else
184(20)
One-Way Selection
185(2)
Two-Way Selection
187(4)
Compound (Block of) Statements
191(1)
Multiple Selections: Nested if
192(3)
Comparing if...else Statements with a Series of if Statements
195(1)
Using Pseudocode to Develop, Test, and Debug a Program
196(3)
Input Failure and the if Statement
199(3)
Confusion Between the Equality Operator (==) and the Assignment Operator (=)
202(1)
Conditional Operator (?:)
203(1)
switch Structures
204(7)
Terminating a Program with the assert Function
211(3)
Programming Example: Cable Company Billing
214(5)
Quick Review
219(2)
Exercises
221(5)
Programming Exercises
226(5)
Control Structures II (Repetition)
231(78)
Why Is Repetition Needed?
232(1)
while Looping (Repetition) Structure
233(17)
Case 1: Counter-Controlled while Loops
236(2)
Case 2: Sentinel-Controlled while Loops
238(5)
Case 3: Flag-Controlled while Loops
243(4)
Case 4: EOF-Controlled while Loops
247(1)
eof Function
248(1)
More on Expressions in while Statements
249(1)
Programming Example: Checking Account Balance
250(9)
Programming Example: Fibonacci Number
259(5)
for Looping (Repetition) Structure
264(6)
Programming Example: Classifying Numbers
270(4)
do...while Looping (Repetition) Structure
274(5)
break and continue Statements
279(2)
Nested Control Structures
281(8)
Quick Review
289(2)
Exercises
291(11)
Programming Exercises
302(7)
User-Defined Functions I
309(36)
Predefined Functions
310(3)
User-Defined Functions
313(1)
Value-Returning Functions
314(14)
Syntax: Value-Returning function
316(1)
Syntax: Formal Parameter List
316(1)
Function Call
316(1)
Syntax: Actual Parameter List
316(1)
return Statement
317(1)
Syntax: return Statement
317(3)
Function Prototype
320(1)
Syntax: Function Prototype
321(6)
Flow of Execution
327(1)
Programming Example: Largest Number
328(1)
Programming Example: Cable Company
329(6)
Quick Review
335(2)
Exercises
337(4)
Programming Exercises
341(4)
User-Defined Functions II
345(74)
Void Functions
346(8)
Void Functions Without Parameters
346(3)
Void Functions with Parameters
349(5)
Value Parameters
354(1)
Reference Variables as Parameters
355(5)
Value and Reference Parameters and Memory Allocation
360(15)
Reference Parameters and Value-Returning Functions
375(1)
Scope of an Identifier
375(4)
Global Variables, Named Constants, and Side Effects
379(1)
Static and Automatic Variables
380(2)
Function Overloading: An Introduction
382(2)
Functions with Default Parameters
384(3)
Programming Example: Classify Numbers
387(5)
Programming Example: Data Comparison
392(10)
Quick Review
402(2)
Exercises
404(7)
Programming Exercises
411(8)
User-Defined Simple Data Types, Namespaces, and the string Type
419(54)
Enumeration Type
420(10)
Declaring Variables
422(1)
Assignment
422(1)
Operations on Enumeration Types
423(1)
Relational Operators
423(1)
Input/Output of Enumeration Types
424(2)
Functions and Enumeration Types
426(2)
Declaring Variables When Defining the Enumeration Type
428(1)
Anonymous Data Types
428(1)
typedef Statement
429(1)
Programming Example: The Game of Rock, Paper, and Scissors
430(11)
Namespaces
441(5)
string Type
446(12)
Additional string Operations
450(1)
length Function
450(2)
size Function
452(1)
find Function
453(3)
substr Function
456(2)
swap Function
458(1)
Programming Example: Pig Latin Strings
458(6)
Quick Review
464(3)
Exercises
467(3)
Programming Exercises
470(3)
Arrays and Strings
473(78)
Arrays
475(21)
Accessing Array Components
476(3)
Processing One-Dimensional Arrays
479(4)
Array Index Out of Bounds
483(1)
Array Initialization During Declaration
484(1)
Partial Initialization of Arrays During Declaration
484(1)
Some Restrictions on Array Processing
485(1)
Arrays as Parameters to Functions
486(1)
Constant Arrays as Formal Parameters
487(2)
Base Address of an Array and Array in Computer Memory
489(3)
Functions Cannot Return a Value of the Type array
492(3)
Integral Data Type and Array Indices
495(1)
Other Ways to Declare Arrays
495(1)
C-strings (Character Arrays)
496(7)
String Comparison
498(2)
Reading and Writing Strings
500(1)
String Input
500(1)
String Output
501(1)
Specifying Input/Output Files at Execution Time
502(1)
string Type and Input/Output Files
502(1)
Parallel Arrays
503(1)
Two- and Multidimensional Arrays
504(18)
Accessing Array Components
506(1)
Two-Dimensional Array Initialization During Declaration
507(1)
Two-Dimensional Arrays and Enumeration Types
507(4)
Initialization
511(1)
Print
511(1)
Input
511(1)
Sum by Row
512(1)
Sum by Column
512(1)
Largest Element in Each Row and Each Column
512(1)
Reversing Diagonal
513(2)
Passing Two-Dimensional Arrays as Parameters to Functions
515(3)
Arrays of Strings
518(1)
Arrays of Strings and the string Type
518(1)
Arrays of Strings and C-Strings (Character Arrays)
519(1)
Another Way to Declare a Two-Dimensional Array
520(1)
Multidimensional Arrays
521(1)
Programming Example: Code Detection
522(7)
Programming Example: Text Processing
529(7)
Quick Review
536(2)
Exercises
538(5)
Programming Exercises
543(8)
Applications of Arrays (Searching and Sorting) and the vector Type
551(58)
List Processing
552(28)
Searching
552(5)
Bubble Sort
557(4)
Selection Sort
561(4)
Insertion Sort
565(7)
Sequential Search on an Ordered List
572(3)
Binary Search
575(3)
Performance of Binary Search
578(2)
vector Type (class)
580(5)
Programming Example: Election Results
585(16)
Quick Review
601(1)
Exercises
602(3)
Programming Exercises
605(4)
Records (structS)
609(40)
Records (structs)
610(17)
Accessing struct Members
612(2)
Assignment
614(1)
Comparison (Relational Operators)
615(1)
Input/Output
616(1)
struct Variables and Functions
616(1)
Arrays versus structs
617(1)
Arrays in structs
618(2)
structs in Arrays
620(3)
structs within a struct
623(4)
Programming Example: Sales Data Analysis
627(16)
Quick Review
643(1)
Exercises
644(2)
Programming Exercises
646(3)
Classes and Data Abstraction
649(76)
Classes
650(33)
Unified Modeling Language Class Diagrams
653(1)
Variable (Object) Declaration
654(1)
Accessing Class Members
655(1)
Built-in Operations on Classes
656(1)
Assignment Operator and Classes
657(1)
Class Scope
658(1)
Functions and Classes
658(1)
Reference Parameters and Class Objects (Variables)
658(1)
Implementation of Member Functions
659(5)
Accessor and Mutator Functions
664(6)
Order of public and private Members of a Class
670(2)
Constructors
672(2)
Invoking a Constructor
674(1)
Invoking the Default Constructor
674(1)
Invoking a Constructor with Parameters
675(3)
Constructors and Default Parameters
678(2)
Classes and Constructors: A Precaution
680(1)
Arrays of Class Objects (Variables) and Constructors
681(2)
Destructors
683(1)
Data Abstraction, Classes, and Abstract Data Types
683(3)
A struct Versus a class
686(1)
Information Hiding
687(4)
Executable Code
691(3)
Static Members of a Class
694(6)
Programming Example: Candy Machine
700(15)
Quick Review
715(2)
Exercises
717(5)
Programming Exercises
722(3)
Inheritance and Composition
725(66)
Inheritance
726(25)
Redefining (Overriding) Member Functions of the Base Class
729(7)
Constructors of Derived and Base Classes
736(8)
Multiple Inclusions of a Header File
744(2)
C++ Stream Classes
746(1)
Protected Members of a Class
747(1)
Inheritance as public, protected, or private
747(4)
Composition
751(5)
Object-Oriented Design (OOD) and Object-Oriented Programming (OOP)
756(3)
Identifying Classes, Objects, and Operations
758(1)
Programming Example: Grade Report
759(20)
Quick Review
779(1)
Exercises
780(6)
Programming Exercises
786(5)
Pointers, Classes, Virtual Functions, and Abstract Classes
791(68)
Pointer Data Type and Pointer Variables
792(1)
Declaring Pointer Variables
792(1)
Address of Operator (&)
793(1)
Dereferencing Operator (*)
794(6)
Classes, Structs, and Pointer Variables
800(3)
Initializing Pointer Variables
803(1)
Dynamic Variables
803(4)
Operator new
804(1)
Operator delete
805(2)
Operations on Pointer Variables
807(2)
Dynamic Arrays
809(7)
Functions and Pointers
812(1)
Pointers and Function Return Values
812(1)
Dynamic Two-Dimensional Arrays
813(3)
Shallow versus Deep Copy and Pointers
816(2)
Classes and Pointers: Some Peculiarities
818(11)
Destructor
819(1)
Assignment Operator
820(2)
Copy Constructor
822(7)
Inheritance, Pointers, and Virtual Functions
829(7)
Classes and Virtual Destructors
836(1)
Abstract Classes and Pure Virtual Functions
836(8)
Address of Operator and Classes
844(3)
Quick Review
847(3)
Exercises
850(7)
Programming Exercises
857(2)
Overloading and Templates
859(90)
Why Operator Overloading Is Needed
860(40)
Operator Overloading
861(1)
Syntax for Operator Functions
862(1)
Overloading an Operator: Some Restrictions
862(1)
Pointer this
863(5)
Friend Functions of Classes
868(3)
Operator Functions as Member Functions and Nonmember Functions
871(3)
Overloading Binary Operators
874(6)
Overloading the Stream Insertion (<) and Extraction (>) Operators
880(5)
Overloading the Assignment Operator (=)
885(8)
Overloading Unary Operators
893(6)
Operator Overloading: Member versus Nonmember
899(1)
Classes and Pointer Member Variables (Revisited)
900(1)
Operator Overloading: One Final Word
900(1)
Programming Example: clockType
900(8)
Programming Example: Complex Numbers
908(6)
Overloading the Array Index (Subscript) Operator ([])
914(2)
Programming Example: newString
916(6)
Function Overloading
922(1)
Templates
923(10)
Function Templates
923(2)
Class Templates
925(8)
Quick Review
933(2)
Exercises
935(5)
Programming Exercises
940(9)
Exception Handling
949(38)
Handling Exceptions within a Program
950(15)
C++ Mechanisms of Exception Handling
954(1)
try/catch Block
954(7)
Using C++ Exception Classes
961(4)
Creating Your Own Exception Classes
965(10)
Rethrowing and Throwing an Exception
971(4)
Exception Handling Techniques
975(2)
Terminate the Program
975(1)
Fix the Error and Continue
976(1)
Log the Error and Continue
977(1)
Stack Unwinding
977(4)
Quick Review
981(2)
Exercises
983(3)
Programming Exercises
986(1)
Recursion
987(36)
Recursive Definitions
988(4)
Direct and Indirect Recursion
991(1)
Infinite Recursion
991(1)
Problem Solving Using Recursion
992(12)
Tower of Hanoi: Analysis
1003(1)
Recursion or Iteration?
1004(1)
Programming Example: Converting a Number from Binary to Decimal
1005(5)
Programming Example: Converting a Number from Decimal to Binary
1010(4)
Quick Review
1014(1)
Exercises
1015(3)
Programming Exercises
1018(5)
Linked Lists
1023(94)
Linked Lists
1024(14)
Linked Lists: Some Properties
1025(9)
Building a Linked List
1034(4)
Linked List as an ADT
1038(13)
Structure of Linked List Nodes
1040(1)
Member Variables of the class linkedListType
1040(1)
Linked List Iterators
1040(7)
Print the List
1047(1)
Length of a List
1047(1)
Retrieve the Data of the First Node
1048(1)
Retrieve the Data of the Last Node
1048(1)
Begin and End
1048(1)
Copy the List
1049(1)
Destructor
1050(1)
Copy Constructor
1050(1)
Overloading the Assignment Operator
1051(1)
Unordered Linked Lists
1051(9)
Search the List
1052(1)
Insert the First Node
1053(1)
Insert the Last Node
1054(5)
Header File of the Unordered Linked List
1059(1)
Ordered Linked Lists
1060(12)
Search the List
1062(1)
Insert a Node
1062(5)
Insert First and Insert Last
1067(1)
Delete a Node
1068(1)
Header File of the Ordered Linked List
1069(3)
Print a Linked list in Reverse Order (Recursion Revisited)
1072(3)
Doubly Linked Lists
1075(11)
Default Constructor
1078(1)
isEmptyList
1078(1)
Destroy the List
1078(1)
Initialize the List
1079(1)
Length of the List
1079(1)
Print the List
1079(1)
Reverse Print the List
1079(1)
Search the List
1080(1)
First and Last Elements
1080(6)
Circular Linked Lists
1086(1)
Programming Example: Video Store
1087(19)
Quick Review
1106(1)
Exercises
1107(4)
Programming Exercises
1111(6)
Stacks and Queues
1117(108)
Stacks
1118(4)
Stack Operations
1120(2)
Implementation of Stacks as Arrays
1122(14)
Initialize Stack
1125(1)
Empty Stack
1126(1)
Full Stack
1126(1)
Push
1126(2)
Return the Top Element
1128(1)
Pop
1128(2)
Copy Stack
1130(1)
Constructor and Destructor
1130(1)
Copy Constructor
1131(1)
Overloading the Assignment Operator (=)
1131(1)
Stack Header File
1132(4)
Programming Example: Highest GPA
1136(4)
Linked Implementation of Stacks
1140(14)
Default Constructor
1143(1)
Empty Stack and Full Stack
1144(1)
Initialize Stack
1144(1)
Push
1145(2)
Return the Top Element
1147(1)
Pop
1147(2)
Copy Stack
1149(1)
Constructors and Destructors
1150(1)
Overloading the Assignment Operator (=)
1150(2)
Stack as Derived from the class unorderedLinkedList
1152(2)
Application of Stacks: Postfix Expressions Calculator
1154(12)
Main Algorithm
1159(1)
Function evaluateExpression
1159(2)
Function evaluateOpr
1161(2)
Function discardExp
1163(1)
Function printResult
1163(3)
Removing Recursion: Nonrecursive Algorithm to Print a Linked List Backward
1166(7)
Queues
1173(19)
Queue Operations
1173(2)
Implementation of Queues as Arrays
1175(11)
Linked Implementation of Queues
1186(5)
Queue Derived from the class unorderedLinkedListType
1191(1)
Application of Queues: Simulation
1192(20)
Designing a Queuing System
1193(1)
Customer
1194(3)
Server
1197(3)
Server List
1200(5)
Waiting Customers Queue
1205(2)
Main Program
1207(5)
Quick Review
1212(1)
Exercises
1213(6)
Programming Exercises
1219(6)
APPENDIX A: RESERVED WORDS
1225(2)
APPENDIX B: OPERATOR PRECEDENCE
1227(2)
APPENDIX C: CHARACTER SETS
1229(4)
ASCII (American Standard Code for Information Interchange)
1229(1)
EBCDIC (Extended Binary Coded Decimal Interchange Code)
1230(3)
APPENDIX D: OPERATOR OVERLOADING
1233(2)
APPENDIX E: ADDITIONAL C++ TOPICS
1235(20)
Binary (Base 2) Representation of a Non-Negative Integer
1235(3)
Converting a Base 10 Number to a Binary Number (Base 2)
1235(2)
Converting a Binary Number (Base 2) to Base 10
1237(1)
More on File Input/Output
1238(14)
Binary Files
1238(6)
Random File Access
1244(8)
Naming Conventions of Header Files in ANSI/ISO Standard C++ and Standard C++
1252(3)
APPENDIX F: HEADER FILES
1255(10)
Header File cassert (assert.h)
1255(1)
Header File cctype (ctype.h)
1256(1)
Header File cfloat (float.h)
1257(1)
Header File climits (limits.h)
1258(2)
Header File cmath (math.h)
1260(5)
Header File cstddef (stddef.h)
1261(1)
Header File cstring (string.h)
1261(4)
APPENDIX G: MEMORY SIZE ON A SYSTEM AND RANDOM NUMBER GENERATOR
1265(2)
Random Number Generator
1266(1)
APPENDIX H: STANDARD TEMPLATE LIBRARY (STL)
1267(42)
Components of the STL
1267(1)
Container Types
1268(24)
Sequence Containers
1268(1)
Sequence Container: Vectors
1268(9)
Member Functions Common to All Containers
1277(2)
Member Functions Common to Sequence Containers
1279(1)
copy Algorithm
1280(4)
Sequence Container: deque
1284(3)
Sequence Container: list
1287(5)
Iterators
1292(5)
IO Stream Iterators
1293(1)
Container Adapters
1293(4)
Algorithms
1297(12)
STL Algorithm Classification
1297(3)
STL Algorithms
1300(1)
Functions fill and fill_n
1300(2)
Functions find and find_if
1302(1)
Functions remove and replace
1303(2)
Functions search, sort, and binary_search
1305(4)
APPENDIX I: ANSWERS TO ODD NUMBERED EXERCISES
1309(22)
Chapter 1
1309(2)
Chapter 2
1311(2)
Chapter 3
1313(1)
Chapter 4
1314(1)
Chapter 5
1315(1)
Chapter 6
1316(1)
Chapter 7
1317(1)
Chapter 8
1318(1)
Chapter 9
1318(1)
Chapter 10
1319(1)
Chapter 11
1320(1)
Chapter 12
1321(2)
Chapter 13
1323(1)
Chapter 14
1324(1)
Chapter 15
1325(1)
Chapter 16
1326(1)
Chapter 17
1327(1)
Chapter 18
1328(1)
Chapter 19
1328(3)
Index 1331

Supplemental Materials

What is included with this book?

The New copy of this book will include any supplemental materials advertised. Please check the title of the book to determine if it should include any access cards, study guides, lab manuals, CDs, etc.

The Used, Rental and eBook copies of this book are not guaranteed to include any supplemental materials. Typically, only the book itself is included. This is true even if the title states it includes any access cards, study guides, lab manuals, CDs, etc.

Rewards Program