Advertisement
Guest User

Untitled

a guest
May 21st, 2010
3,069
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  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
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement