## Table of Contents

1. Introduction

1.1 Programming (general)

1.2 Programming basics

1.3 Comments and whitespace

1.4 Brief history

1.5 Computers all around us

1.6 Representing information as bits

1.7 Problem solving

1.8 Why programming

1.9 Code and pseudocode

2. Variables / Assignments

2.1 Variables and assignments (general)

2.2 Variables (integer)

2.3 Identifiers

2.4 Arithmetic expressions (general)

2.5 Arithmetic expressions (integer)

2.6 Example: Health data

2.7 Floating-point numbers (float)

2.8 Using math functions

2.9 Random numbers

2.10 Integer division

2.11 Type conversions

2.12 Modulo operator

2.13 Data types

2.14 Constants

2.15 Code: Variables and assignments

3. Branches

3.1 Branches

3.2 More branches

3.3 Equality and relational operators

3.4 Detecting ranges using branches

3.5 Logical operators

3.6 Order of evaluation

3.7 Example: Toll calculation

3.8 Floating-point comparison

3.9 Code: Branches

3.10 MIPSzy simulators

4. Loops

4.1 Loops (general)

4.2 Loop basics

4.3 More loop examples

4.4 Looping N times

4.5 Loop examples iterating N times

4.6 While and for loops

4.7 Nested loops

4.8 Code: While loops

4.9 Code: For loops

5. Arrays

5.1 Array concept (general)

5.2 Arrays

5.3 Array iteration drill

5.4 Iterating through arrays

5.5 Swapping two variables (general)

5.6 Code: Arrays

6. User-Defined Functions

6. User-Defined Functions

6.1 User-defined function basics

6.2 Return

6.3 Reasons for defining functions

6.4 Functions with branches/loops

6.5 Code: Functions

6.6 Code: Functions with array parameters

7. Software Topics

7.1 Algorithms

7.2 Language survey

7.3 Libraries

8. Troubleshooting Process

8.1 Troubleshooting: Hypotheses and tests

8.2 Logic of troubleshooting

8.3 Creating hypotheses

8.4 Ex: iPhone headset

8.5 Ex: USB car charger

9. Programs

9.1 Introduction: Hello World!

9.2 Introduction: No parking sign

9.3 Introduction: House real estate summary

9.4 Introduction: Caffeine levels

9.5 Variables/Assignments: Divide by x

9.6 Variables/Assignments: Driving costs

9.7 Variables/Assignments: Simple statistics

9.8 Variables/Assignments: Using math functions

9.9 Variables/Assignments: Musical note frequencies

9.10 Variables/Assignments: Phone number breakdown

9.11 Branches: Largest number

9.12 Branches: Remove gray from RGB

9.13 Branches: Leap Year

9.14 Loops: Convert to binary

9.15 Loops: Varied amount of input data

9.16 Loops: Output range with increment of 10

9.17 Loops: Countdown until matching digits

9.18 Loops: Brute force equation solver

9.19 Arrays: Output numbers in reverse

9.20 Arrays: Middle item

9.21 Arrays: Output values below an amount

9.22 User-Defined Functions: Miles to track laps

9.23 User-Defined Functions: Max magnitude

9.24 User-Defined Functions: Driving cost

9.25 User-Defined Functions: Step counter

9.26 User-Defined Functions: Flip a coin

9.27 User-Defined Functions: A jiffy

9.28 User-Defined Functions: Leap year

9.29 User-Defined Functions: Max and min numbers

9.30 User-Defined Functions: Convert to binary

9.31 User-Defined Functions: Output values below an amount

9.32 User-Defined Functions: Adjust list by normalizing

10. Algorithms

10.1 Introduction to algorithms

10.2 Algorithm efficiency

10.3 Searching and algorithms

10.4 Binary search

10.5 Sorting: Introduction

10.6 Heuristics

## What You’ll Find In This zyBook:

### More action with less text.

- Provides an exceptionally approachable introduction to programming concepts
- Initially uses flowcharts to teach basic programming concepts including variables, data types, assignment statements, arithmetic operations, decisions, loops, arrays, and functions. For each, also teaches coding.
- Uses a new ultra-simple programming language, Coral, having unified flowchart and code version, and coming with a free web-based educational simulator.
- Also introduces basic troubleshooting/debugging techniques, and overviews program design methods including waterfall and agile design processes, UML, libraries, and more.
- Includes 100s of learning questions, and numerous auto-generated auto-graded homework exercises.

## The zyBooks Approach

### Less text doesn’t mean less learning.

Many teachers realize that students in introductory programming courses not only have to learn fundamental programming concepts, but also have to learn non-ideal detailed syntax and semantics of a specific industry programming language. An alternative approach, used in this zyBook, is to first teach programming concepts in a language-neutral manner, thereby enabling students to master those concepts before having to learn details of a specific programming language. This material teaches programming using a flowchart language, which is more approachable yet maintains the precision of a programming language (and is executable so is fun). The material also teaches how to convert a flowchart to a simple code language, enabling a gradual learning path from flowcharts to code to an industry programming language.

The zyBook contains animations of most concepts, helping readers to “see” the concepts and build an intuitive understanding. The zyBook also makes extensive use of our web-based educational simulator, so that nearly every example can be run by the student.

## Authors

**Roman Lysecky**

*Professor of Electrical and Computer Engineering, Univ. of Arizona*

**Frank Vahid**

*Professor of Computer Science and Engineering, Univ. of California, Riverside*