Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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.
- For example:
- // Printing the alphabet
- int count = 0
- char letter = 'a'
- while ( count < 26 )
- print letter
- a ++
- count ++
- endwhile
- 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.
- For example:
- // Waiting for the user
- while ( ! user clicks a button )
- print "waiting for user to click a button..."
- delay ( 100 )
- endwhile
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement