Control structures

  • if/else
    • simple branching
  • switch case
    • more complicate branching
    • for multiple cases
    • like if the input is 1, go to first base, 2 go to second base, 3 go to third, 4 home run, default strike out
    • after each case, be sure to add break; otherwise, it'll keep on going
  • for loop
    • good for loop a set number of times
    • like looping through all the pins
  • while
    • good for loop an unknown number of times
    • maybe for forever
    • maybe until something happens to break out

Copyright Mike Edwards 2006-2009. All content available under the Creative Commons Attribution ShareAlike license, unless otherwise noted.