Preface xiii <br> Chapter 1 Introduction to Computers and Programming 1 <br>1.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 <br>1.2 Hardware . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 <br>1.3 How Computers Store Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 <br>1.4 How a Program Works . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 <br>1.5 Types of Software . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 <br>Review Questions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 <br> Chapter 2 Input, Processing, and Output 29 <br>2.1 Designing a Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29 <br>2.2 Output, Input, and Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34 <br>2.3 Variable Assignment and Calculations . . . . . . . . . . . . . . . . . . . . . . . . . . 43 <br>IN THE SPOTLIGHT: Calculating a Percentage . . . . . . . . . . . . . . . . . . . . . . . . . . . 47 <br>IN THE SPOTLIGHT: Calculating an Average . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50 <br>IN THE SPOTLIGHT: Converting a Math Formula to a <br>Programming Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53 <br>2.4 Variable Declarations and Data Types . . . . . . . . . . . . . . . . . . . . . . . . . . . 56 <br>2.5 Named Constants . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62 <br>2.6 Hand Tracing a Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 <br>2.7 Documenting a Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64 <br>IN THE SPOTLIGHT: Using Named Constants, Style Conventions, <br>and Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66 <br>Review Questions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68 <br>Programming Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72 <br> Chapter 3 Modules 75 <br>3.1 Introduction to Modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75 <br>3.2 Defining and Calling a Module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78 <br>IN THE SPOTLIGHT: Defining and Calling Modules . . . . . . . . . . . . . . . . . . . . . . . 84 <br>3.3 Local Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88 <br>3.4 Passing Arguments to Modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90 <br>IN THE SPOTLIGHT: Passing an Argument to a Module . . . . . . . . . . . . . . . . . . . . 95 <br>IN THE SPOTLIGHT: Passing an Argument by Reference . . . . . . . . . . . . . . . . . . . 100 <br>3.5 Global Variables and Global Constants . . . . . . . . . . . . . . . . . . . . . . . . . 104 <br>IN THE SPOTLIGHT: Using Global Constants . . . . . . . . . . . . . . . . . . . . . . . . . . . 105 <br>Review Questions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109 <br>Programming Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113 <br> Chapter 4 Decision Structures and Boolean Logic 115 <br>4.1 Introduction to Decision Structures . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115 <br>IN THE SPOTLIGHT: Using the If-Then Statement . . . . . . . . . . . . . . . . . . . . . . . 122 <br>4.2 Dual Alternative Decision Structures . . . . . . . . . . . . . . . . . . . . . . . . . . . 125 <br>IN THE SPOTLIGHT: Using the If-Then-Else Statement . . . . . . . . . . . . . . . . . . 126 <br>4.3 Comparing S