|
Problem Solving With C++ 7th Edition Pearson International Edition
Now featuring new Video Notes the Seventh Edition ofProblem Solving with C++ continues to be the most widely used textbook by students and instructors in the introduction to programming and C++ language course. Through each edition, hundreds and thousands of students have valued Walt Savitch's approach to programming, which emphasizes active reading
through the use of well-placed examples and self-test examples. Created for the beginner, this book focuses on cultivating strong problem-solving and programming techniques while introducing students to the C++ programming language.
CONTENTS:
Chapter 1 Introduction to Computers and C++ Programming 1 1.1 COMPUTER SYSTEMS 2 Hardware 2 Software 7 High-Level Languages 8 Compilers 9 History Note 12 1.2 PROGRAMMING AND PROBLEM-SOLVING 12 Algorithms 12 Program Design 15 Object-Oriented Programming 17 The Software Life Cycle 17 1.3 INTRODUCTION TO C++ 19 Origins of the C++ Language 19 A Sample C++ Program 20 Pitfall: Using the Wrong Slash in \n 24 Programming Tip: Input and Output Syntax 24 Layout of a Simple C++ Program 24 Pitfall: Putting a Space before the include File Name 26 Compiling and Running a C++ Program 27 Programming Tip: Getting Your Program to Run 27 1.4 TESTING AND DEBUGGING 30 Kinds of Program Errors 30 Pitfall: Assuming Your Program Is Correct 31 Chapter Summary 32 Answers to Self-Test Exercises 33 Programming Projects 36 Chapter 2 C++ Basics 39 2.1 VARIABLES AND ASSIGNMENTS 40 Variables 40 Names: Identifiers 42 Variable Declarations 44 Assignment Statements 45 Pitfall: Uninitialized Variables 47 Programming Tip: Use Meaningful Names 49 2.2 INPUT AND OUTPUT 50 Output Using cout 50 Include Directives and Namespaces 52 Escape Sequences 53 Programming Tip: End Each Program with a \n or endl 55 Formatting for Numbers with a Decimal Point 55 Input Using cin 56 Designing Input and Output 58 Programming Tip: Line Breaks in I/O 58 2.3 DATA TYPES AND EXPRESSIONS 60 The Types int and double 60 Other Number Types 62 The Type char 63 The Type bool 64 Introduction to the Class string 65 Type Compatibilities 66 Arithmetic Operators and Expressions 69 Pitfall: Whole Numbers in Division 71 More Assignment Statements 73 2.4 SIMPLE FLOW OF CONTROL 74 A Simple Branching Mechanism 74 Pitfall: Strings of Inequalities 80 Pitfall: Using = in place of == 81 Compound Statements 82 Simple Loop Mechanisms 84 Increment and Decrement Operators 87 Programming Example: Charge Card Balance 89 Pitfall: Infinite Loops 90 2.5 PROGRAM STYLE 93 Indenting 93 Comments 94 Naming Constants 96 Chapter Summary 98 Answers to Self-Test Exercises 99 Programming Projects 104 Chapter 3 More Flow of Control 111 3.1 USING BOOLEAN EXPRESSIONS 112 Evaluating Boolean Expressions 112 Pitfall: Boolean Expressions Convert to int Values 116 Enumeration Types (Optional) 119 3.2 MULTIWAY BRANCHES 120 Nested Statements 120 Programming Tip: Use Braces in Nested Statements 121 Multiway if-else Statements 123 Programming Example: State Income Tax 125 The switch Statement 129 Pitfall: Forgetting a break in a switch Statement 133 Using switch Statements for Menus 134 Blocks 134 Pitfall: Inadvertent Local Variables 139 3.3 MORE ABOUT C++ LOOP STATEMENTS 140 The while Statements Reviewed 141 Increment and Decrement Operators Revisited 142 The for Statement 145 Pitfall: Extra Semicolon in a for Statement 150 What Kind of Loop to Use 151 Pitfall: Uninitialized Variables and Infinite Loops 153 The break Statement 153 Pitfall: The break Statement in Nested Loops 155 3.4 DESIGNING LOOPS 156 Loops for Sums and Products 156 Ending a Loop 157 Nested Loops 161 Debugging Loops 163 Chapter Summary 166 Answers to Self-Test Exercises 167 Programming Projects 173 Chapter 4 Procedural Abstraction and Functions That Return a Value 181 4.1 TOP-DOWN DESIGN 182 4.2 PREDEFINED FUNCTIONS 183 Using Predefined Functions 183 Type Casting 188 Older Form of Type Casting 190 Pitfall: Integer Division Drops the Fractional Part 191 4.3 PROGRAMMER-DEFINED FUNCTIONS 192 Function Definitions 192 Functions That Return a Boolean Value 196 Alternate Form for Function Declarations 199 Pitfall: Arguments in the Wrong Order 199 Function Definition-Syntax Summary 201 More About Placement of Function Definitions 202 Programming Tip: Use Function Calls in Branching Statements 202 4.4 PROCEDURAL ABSTRACTION 204 The Black Box Analogy 204 Programming Tip: Choosing Formal Parameter Names 206 Programming Tip: Nested Loops 208 Case Study: Buying Pizza 211 Programming
Be the first to write a Customer review
|