Pastebin launched a little side project called HostCabi.net, check it out ;-)Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 21st, 2010  |  syntax: None  |  size: 0.71 KB  |  hits: 2,371  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. A condition-controlled loop will keep repeating until a specific condition is met while a count-controlled loop will run a specific number of times. It would be better to use a count-controlled loop when performing a task that has a pre-known amount of loops.
  2.  
  3. For example:
  4. // Printing the alphabet
  5. int count = 0
  6. char letter = 'a'
  7. while ( count < 26 )
  8.         print letter
  9.         a ++
  10.         count ++
  11. endwhile
  12.  
  13. It would be better to use a condition controlled loop when waiting for an event to happen to terminate the while or the amount of loops to run depends on another variable.
  14.  
  15. For example:
  16. // Waiting for the user
  17. while ( ! user clicks a button )
  18.         print "waiting for user to click a button..."
  19.         delay ( 100 )
  20. endwhile