Starting Out with C++ : From Control Structures Through Objects

Why Rent from Knetbooks?

Because Knetbooks knows college students. Our rental program is designed to save you time and money. Whether you need a textbook for a semester, quarter or even a summer session, we have an option for you. Simply select a rental period, enter your information and your book will be on its way!

Starting Out with C++: From Control Structures through Objects is the favorite textbook of instructors who place an emphasis on problem-solving and program design in their introduction to C++ course. Tony Gaddis' gradual and accessible approach to teaching programming concepts gives students the right amount of detail needed to master programming skills. Book jacket.

Preface

xiii

Introduction to Computers and Programming

1

(28)

Why Program?

1

(1)

Computer Systems: Hardware and Software

2

(4)

Programs and Programming Languages

6

(6)

What Is a Program Made of?

12

(4)

Input, Processing, and Output

16

(1)

The Programming Process

17

(4)

Procedural and Object-Oriented Programming

21

(8)

Introduction to C++

29

(52)

The Parts of a C++ Program

29

(4)

The cout Object

33

(4)

The #include Directive

37

(2)

Variables and Literals

39

(3)

Identifiers

42

(2)

Integer Data Types

44

(4)

The char Data Type

48

(5)

Floating-Point Data Types

53

(4)

The bool Data Type

57

(1)

Determining the Size of a Data Type

58

(1)

Variable Assignments and Initialization

59

(1)

Scope

60

(1)

Arithmetic Operators

61

(4)

Comments

65

(2)

Focus on Software Engineering: Programming Style

67

(2)

If You Plan to Continue in Computer Science: Standard and Prestandard C++

69

(12)

Expressions and Interactivity

81

(82)

The cin Object

81

(8)

Mathematical Expressions

89

(8)

When You Mix Apples and Oranges: Type Conversion

97

(2)

Overflow and Underflow

99

(1)

Type Casting

100

(4)

Named Constants

104

(5)

Multiple Assignment and Combined Assignment

109

(4)

Formatting Output

113

(10)

Formatted Input

123

(5)

Focus on Object-Oriented Programming: More About Member Functions

128

(1)

More Mathematical Library Functions

128

(4)

Focus on Debugging: Hand Tracing a Program

132

(2)

Focus on Problem Solving: A Case Study

134

(4)

Introduction to File Input and Output

138

(25)

Making Decisions

163

(84)

Relational Operators

163

(5)

The if Statement

168

(8)

Flags

176

(1)

Expanding the if Statement

177

(4)

The if/else Statement

181

(3)

The if/else if Statement

184

(5)

Using a Trailing else

189

(1)

Menus

190

(2)

Focus on Software Engineering: Nested if Statements

192

(6)

Logical Operators

198

(6)

Checking Numeric Ranges with Logical Operators

204

(2)

Focus on Software Engineering: Validating User Input

206

(2)

More About Variable Definitions and Scope

208

(4)

Comparing Strings

212

(5)

The Conditional Operator

217

(4)

The switch Statement

221

(9)

Testing for File Open Errors

230

(17)

Looping

247

(52)

The Increment and Decrement Operators

247

(5)

Introduction to Loops: The while Loop

252

(5)

Using the while Loop for Input Validation

257

(3)

Counters

260

(1)

The do-while Loop

261

(5)

The for Loop

266

(9)

Keeping a Running Total

275

(1)

Sentinels

276

(2)

Using a Loop to Read Data from a File

278

(3)

Focus on Software Engineering: Deciding Which Loop to Use

281

(1)

Nested Loops

281

(3)

Breaking Out of a Loop

284

(2)

The continue Statement

286

(13)

Functions

299

(78)

Focus on Software Engineering: Modular Programming

299

(2)

Defining and Calling Functions

301

(8)

Function Prototypes

309

(2)

Sending Data into a Function

311

(5)

Passing Data by Value

316

(2)

Focus on Software Engineering: Using Functions in a Menu-Driven Program

318

(4)

The return Statement

322

(2)

Returning a Value from a Function

324

(6)

Returning a Boolean Value

330

(2)

Local and Global Variables

332

(7)

Static Local Variables

339

(4)

Default Arguments

343

(4)

Using Reference Variables as Parameters

347

(5)

Overloading Functions

352

(5)

The exit( ) Function

357

(2)

Stubs and Drivers

359

(18)

Arrays

377

(78)

Arrays Hold Multiple Values

377

(2)

Accessing Array Elements

379

(7)

No Bounds Checking in C++

386

(3)

Array Initialization

389

(5)

Processing Array Contents

394

(8)

Focus on Software Engineering: Using Parallel Arrays

402

(3)

Arrays as Function Arguments

405

(10)

Two-Dimensional Arrays

415

(7)

Arrays of Strings

422

(2)

Arrays with Three or More Dimensions

424

(2)

Focus on Problem Solving and Program Design: A Case Study

426

(2)

If You Plan to Continue in Computer Science: Introduction to the STL vector

428

(27)

Searching and Sorting Arrays

455

(40)

Focus on Software Engineering: Introduction to Search Algorithms

455

(7)

Focus on Problem Solving and Program Design: A Case Study

462

(6)

Focus on Software Engineering: Introduction to Sorting Algorithms

468

(8)

Focus on Problem Solving and Program Design: A Case Study

476

(8)

If You Plan to Continue in Computer Science: Sorting and Searching vectors