Control Yourself: Chapter 4 of Overland

Control structures are at the core of programming.  As the name implies, they are the basic building blocks of controlling the computer.  By control structures, we typically include conditional constructs and looping or iteration constructs.  One plus here is that the control structures in C++ are nearly identical to the control structures in Java.

Section 4.1 contains a great Cheat Sheet related to control structures.  Of course, as you probably know from Java or other languages, some of the most popular are:

  • if
  • for
  • while

You’ll see that section 4.1 also lists the goto command.  Don’t ever use this.  It create “spaghetti” code.  Spaghetti is a yummy dinner option, not an appropriate adjective for code.

Section 4.7 covers Range-based For loops.  These are new to C++11.  So depending on exactly which version of the G++ compiler you may have running, they may or may not compile in your code.

Make sure you read through and understand the example Number Guessing Game in section 4.11.  Post questions to Piazza if you have any.

Peace, love, c++!

Speak Your Mind

*

*

This site uses Akismet to reduce spam. Learn how your comment data is processed.