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
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

Chapter 2. Directing Program Flow > Using the Conditional Operator

Using the Conditional Operator

We’ve seen how you can make decisions in code using the if statement and execute other code to match the results of those decisions.

You can also use the conditional operator to make decisions. This operator lets you evaluate an expression and execute code depending on the result. The conditional operator has this format:


  

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