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. - Publisher. 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 Preface 1: Introduction To Programming Programming a computer Programmer's job Do I have what it takes to be a programmer? Employment opportunities Brief history of programming languages Machine languages Assembly languages High-level languages Control structure Sequence structure Selection structure Repetition structure Summary Key terms Review questions Exercises 2: Beginning The Problem-Solving Process Problem solving Solving everyday problems Creating computer solutions to problems Step 1-Analyze the problem Step 2-Plan the algorithm Step 3-Desk-check the algorithm Gas mileage problem Summary Key terms Review questions Exercises 3: Variables And Constants Beginning step 4 in the problem-solving process Internal memory Selecting a name for a memory location Revisiting the Treyson Mobley problem Selecting a data type for a memory location How data is stored in internal memory Selecting an initial value for a memory location Declaring a memory location Summary Key terms Review questions Exercises 4: Completing The Problem-Solving Process Finishing step 4 in the problem-solving process Getting data from the keyboard Displaying messages on the computer screen Arithmetic operators in C++ Type conversions in arithmetic expressions Static_cast operator Assignment statements Step 5-Desk check the program Step 6-Evaluate and modify the program Arithmetic assignment operators Summary Key terms Review questions Exercises 5: Selection Structure Making decisions Flowcharting a selection structure Coding a selection structure in C++ Comparison operators Swapping numeric values Displaying the sum or difference Logical operators Using the truth tables Calculating gross pay Pass/fail program Converting a character to uppercase or lowercase Formatting numeric output Summary Key terms Review questions Exercises 6: More On The Selection Structure Making decisions Flowcharting a nested selection structure Coding a nested selection structure Logic errors in selection structures First logic error: Using a compound condition rather than a nested selection structure Second logic error: Reversing the outer and nested decisions Third logic error: Using an unnecessary nested selection structure Multiple-alternative selection structures Switch statement Summary Key terms Review questions Exercises 7: Repetition Structure Repeating program instructions Using a pretest loop to solve a real-world problem Flowcharting a pretest loop While statement Using counters and accumulators Sales express program Counter-controlled pretest loops For statement Holmes supply program Colfax sales program Another version of the Miller Incorporated program Summary Key terms Review questions Exercises 8: More On The Repetition Structure Posttest loops Flowcharting a posttest loop Do while statement Nest repetition structures Asterisks program Savings calculator program Pow function Coding the savings calculator program Modifying the savings calculator program Summary Key terms Review questions Exercises 9: Value-Returning Functions Functions Hypotenuse program Finding the square root of a number Random addition problems program Generating random integers Creating program-defined value-returning functions Calling a function Function prototypes Plano Elementary School program Area calculator program Scope and lifetime of a variable Bonus calculator program Summary Key terms Review questions Exercises 10: Void Functions Void functions Passing variables to a function Reviewing passing variables by value Passing variables by reference Salary program Summary Key terms Review questions Exercises 11: One-Dimensional Arrays Arrays One-dimensional arrays Declaring and initializing a one-dimensional array Entering data into a one-dimensional array Displaying the contents of a one-dimensional array Coding the XYZ company's sales program Passing a one-dimensional array to a function Moonbucks Coffee program-calculating a total and average KL Motors program-searching an array Hourly rate program-accessing an individual element Random numbers program Sorting the data stored in a one-dimensional array Parallel one-dimensional arrays Summary Key terms Review questions Exercises 12: Two-Dimensional Arrays Using two-dimensional arrays Declaring and initializing a two-dimensional array Entering data into a two-dimensional array Displaying the contents of two-dimensional array Coding the Caldwell Company's orders program Accumulating the values stored in a two-dimensional array Searching a two-dimensional array Passing a two-dimensional array to a function Summary Key term Review questions Exercises 13: Strings String data type Creative sales program Getline function Ignore function ZIP code program Determining the number of characters contained in a string variable Accessing the characters contained in a string variable Rearranged name program Searching the contents of a string variable Annual income program Removing characters from a string variable Replacing characters in a string variable Social Security number program Inserting characters within a string variable Company name program Duplicating a character within a string variable Concatenating strings Summary Key terms Review questions Exercises 14: Sequential Access Files File types CD collection program Creating file objects Opening a sequential access file Determining whether a file was opened successfully Writing data to a sequential access file Reading information from a sequential access file Testing for the end of a sequential access file Closing a sequential access file Coding the CD collection program Summary Key terms Review questions Exercises Appendix A: Answers to Mini-Quizzes and Labs Appendix B: C++ Keywords Appendix C: ASCII Codes Appendix D: How to use Microsoft Visual C++ Appendix E: How to use Dev-C++ Appendix F: Classes and objects Object-oriented terminology Defining a class in C++ Instantiating an object and referring to a public member Example 1-Class that contains public data members only Header files Example 2-Class that contains a private data member and public member methods Example 3-Using a class that contains two constructors Example 4-Class that contains overloaded methods Summary Key terms Review questions Exercises From the Publisher: 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
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.