An Introduction to Programming with C++, 6th Edition

This document was uploaded by one of our users. The uploader already confirmed that they had the permission to publish it. If you are author/publisher or own the copyright of this documents, please report to us by using this DMCA report form.

Simply click on the Download Book button.

Yes, Book downloads on Ebookily are 100% Free.

Sometimes the book is free on Amazon As well, so go ahead and hit "Search on Amazon"

An Introduction to Programming with C++, Sixth Edition is the latest C++ offering from Diane Zak. This book is distinct from other textbooks because of its unique approach, which motivates students by demonstrating why they need to learn the concepts and skills presented. Each chapter contains Mini-Quizzes, Labs, and Try This features to help readers practice and absorb the content as they go along. This edition also includes completely new applications and exercises, more IPO charts and flowcharts, and a brand new interior design.

Author(s): Diane Zak
Edition: 6th
Publisher: Course Technology
Year: 2011

Language: English
Pages: 756
Tags: Библиотека;Компьютерная литература;C / C++;

Front Cover......Page 1
Title Page......Page 4
Copyright......Page 5
Brief Contents......Page 7
Contents......Page 9
Preface......Page 15
CHAPTER 1 An Introduction to Programming......Page 22
Do I Have What It Takes to Be a Programmer?......Page 23
Employment Opportunities......Page 24
High-Level Languages......Page 25
The Sequence Structure......Page 27
The Selection Structure......Page 28
The Repetition Structure......Page 30
Key Terms......Page 33
Review Questions......Page 34
Exercises......Page 36
CHAPTER 2 Beginning the Problem-Solving Process......Page 43
Solving Everyday Problems......Page 44
Creating Computer Solutions to Problems......Page 45
Step 1—Analyze the Problem......Page 46
Step 2—Plan the Algorithm......Page 48
Step 3—Desk-Check the Algorithm......Page 52
The Gas Mileage Problem......Page 55
Summary......Page 64
Key Terms......Page 738
Review Questions......Page 65
Exercises......Page 67
CHAPTER 3 Variables and Constants......Page 72
Internal Memory......Page 73
Selecting a Name for a Memory Location......Page 74
Revisiting the Treyson Mobley Problem......Page 75
Selecting a Data Type for a Memory Location......Page 76
How Data Is Stored in Internal Memory......Page 78
Selecting an Initial Value for a Memory Location......Page 81
Declaring a Memory Location......Page 83
Key Terms......Page 90
Review Questions......Page 92
Exercises......Page 94
CHAPTER 4 Completing the Problem-Solving Process......Page 98
Finishing Step 4 in the Problem-Solving Process......Page 99
Getting Data from the Keyboard......Page 100
Displaying Messages on the Computer Screen......Page 102
Arithmetic Operators in C++......Page 104
Type Conversions in Arithmetic Expressions......Page 105
The static_cast Operator......Page 107
Assignment Statements......Page 108
Step 5—Desk-Check the Program......Page 111
Step 6—Evaluate and Modify the Program......Page 113
Arithmetic Assignment Operators......Page 118
Summary......Page 124
Key Terms......Page 126
Review Questions......Page 128
Exercises......Page 130
CHAPTER 5 The Selection Structure......Page 140
Making Decisions......Page 141
Flowcharting a Selection Structure......Page 144
Coding a Selection Structure in C++.......Page 146
Comparison Operators......Page 148
Swapping Numeric Values......Page 149
Displaying the Sum or Difference......Page 151
Logical Operators......Page 153
Using the Truth Tables......Page 155
Calculating Gross Pay......Page 156
Pass/ Fail Program......Page 158
Converting a Character to Uppercase or Lowercase.......Page 161
Formatting Numeric Output......Page 162
Summary......Page 171
Key Terms......Page 172
Review Questions......Page 173
Exercises......Page 175
CHAPTER 6 More on the Selection Structure......Page 184
Making Decisions......Page 185
Flowcharting a Nested Selection Structure......Page 189
Coding a Nested Selection Structure......Page 191
Logic Errors in Selection Structures......Page 194
First Logic Error: Using a Compound Condition Rather Than a Nested Selection Structure......Page 196
Second Logic Error: Reversing the Outer and Nested Decisions......Page 198
Third Logic Error: Using an Unnecessary Nested Selection Structure......Page 199
Multiple-Alternative Selection Structures......Page 201
The switch Statement......Page 204
Key Terms.......Page 217
Review Questions......Page 218
Exercises......Page 221
CHAPTER 7 The Repetition Structure......Page 234
Repeating Program Instructions......Page 235
Using a Pretest Loop to Solve a Real-World Problem......Page 237
Flowcharting a Pretest Loop......Page 240
The while Statement......Page 242
Using Counters and Accumulators......Page 245
The Sales Express Program......Page 246
Counter-Controlled Pretest Loops......Page 249
The for Statement......Page 252
The Holmes Supply Program......Page 254
The Colfax Sales Program......Page 257
Another Version of the Miller Incorporated Program......Page 259
Summary......Page 270
Key Terms......Page 271
Review Questions......Page 272
Exercises......Page 275
CHAPTER 8 More on the Repetition Structure......Page 285
Posttest Loops......Page 286
Flowcharting a Posttest Loop......Page 288
The do while Statement......Page 291
Nested Repetition Structures......Page 294
The Asterisks Program......Page 296
The Savings Calculator Program......Page 304
The pow Function......Page 305
Coding the Savings Calculator Program......Page 307
Modifying the Savings Calculator Program......Page 308
Summary......Page 318
Review Questions......Page 319
Exercises......Page 321
CHAPTER 9 Value-Returning Functions......Page 329
Functions......Page 330
Finding the Square Root of a Number......Page 331
The Random Addition Problems Program......Page 334
Generating Random Integers......Page 335
Creating Program-Defined Value-Returning Functions......Page 343
Calling a Function......Page 347
Function Prototypes......Page 351
The Plano Elementary School Program......Page 354
The Area Calculator Program......Page 357
The Bonus Calculator Program......Page 361
Summary......Page 378
Key Terms......Page 379
Review Questions......Page 380
Exercises......Page 383
CHAPTER 10 Void Functions......Page 391
Void Functions......Page 392
Passing Variables to a Function......Page 397
Reviewing Passing Variables by Value......Page 398
Passing Variables by Reference......Page 400
The Salary Program......Page 405
Summary......Page 422
Review Questions......Page 423
Exercises......Page 427
CHAPTER 11 One-Dimensional Arrays......Page 440
One-Dimensional Arrays......Page 441
Declaring and Initializing a One-Dimensional Array......Page 443
Entering Data into a One-Dimensional Array......Page 445
Displaying the Contents of a One-Dimensional Array......Page 447
Coding the XYZ Company’s Sales Program......Page 448
Passing a One-Dimensional Array to a Function......Page 454
The Moonbucks Coffee Program—Calculating a Total and Average......Page 457
The KL Motors Program—Searching an Array......Page 460
The Hourly Rate Program—Accessing an Individual Element......Page 463
The Random Numbers Program......Page 465
Sorting the Data Stored in a One-Dimensional Array......Page 475
Parallel One-Dimensional Arrays......Page 482
Summary......Page 494
Review Questions......Page 495
Exercises......Page 499
CHAPTER 12 Two-Dimensional Arrays......Page 507
Using Two-Dimensional Arrays......Page 508
Declaring and Initializing a Two-Dimensional Array......Page 510
Entering Data into a Two-Dimensional Array......Page 512
Displaying the Contents of a Two-Dimensional Array......Page 515
Coding the Caldwell Company’s Orders Program......Page 516
Accumulating the Values Stored in a Two-Dimensional Array......Page 519
Searching a Two-Dimensional Array......Page 521
Passing a Two-Dimensional Array to a Function......Page 528
Summary......Page 536
Review Questions......Page 537
Exercises......Page 538
CHAPTER 13 Strings......Page 545
The string Data Type......Page 546
The Creative Sales Program......Page 547
The getline Function......Page 548
The ignore Function......Page 552
Determining the Number of Characters Contained in a string Variable......Page 556
Accessing the Characters Contained in a string Variable......Page 559
Searching the Contents of a string Variable......Page 565
The Annual Income Program......Page 568
Removing Characters from a string Variable......Page 569
Replacing Characters in a string Variable......Page 572
The Social Security Number Program......Page 574
Inserting Characters Within a string Variable......Page 575
The Company Name Program......Page 577
Duplicating a Character Within a string Variable......Page 578
Concatenating Strings......Page 579
Summary......Page 589
Review Questions......Page 591
Exercises......Page 595
CHAPTER 14 Sequential Access Files......Page 603
The CD Collection Program......Page 604
Creating File Objects......Page 606
Opening a Sequential Access File......Page 607
Determining Whether a File Was Opened Successfully......Page 610
Writing Data to a Sequential Access File......Page 611
Reading Information from a Sequential Access File......Page 613
Testing for the End of a Sequential Access File......Page 615
Closing a Sequential Access File......Page 616
Coding the CD Collection Program.......Page 617
Key Terms......Page 635
Review Questions......Page 636
Exercises......Page 639
APPENDIX A: Answers to Mini-Quizzes and Labs......Page 647
APPENDIX B: C++ Keywords......Page 711
APPENDIX C: ASCII Codes......Page 712
APPENDIX D: How to Use Microsoft Visual C++......Page 714
APPENDIX E: How to Use Dev-C++......Page 715
APPENDIX F: Classes and Objects......Page 716
Object-Oriented Terminology......Page 717
Defining a Class in C++......Page 718
Instantiating an Object and Referring to a Public Member......Page 721
Example 1—A Class that Contains Public Data Members Only......Page 723
Header Files......Page 725
Example 2—A Class that Contains a Private Data Member and Public Member Methods......Page 727
Example 3—Using a Class that Contains Two Constructors......Page 730
Example 4—A Class that Contains Overloaded Methods......Page 733
Summary......Page 737
Review Questions......Page 739
Exercises......Page 741
Index......Page 742