Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 2. Directing Program Flow

2. Directing Program Flow

This chapter is all about taking control of your code by making programs flow as you want. You’ll see how to make choices with the if statement, loop over and over with loops, and more.

The primary program flow statement that allows you to make choices is the if statement. With the if statement, you can test a condition and execute code depending on whether or not the statement is true. For example, say you have a variable named temperature, which is set to 72:


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint