What is the do while loop?

December 29th, 2007 by uCertify Leave a reply »

The do while loop is used to execute the statement or a series of statements inside the loop as long as a condition remains true. The loop executes the statements before testing the condition. It ensures that the statements are executed at least once.

In the do while loop, the variable needs to be initialized and increments each time the statements are executed. When the value of variables reaches a specified value, the condition returns false and the loop ends.

The syntax of the do while loop is follows:

do {
statement(s)
} while (condition)

The loop performs the following 4 steps:

  1. Executes the statements inside the loop.
  2. Evaluate the condition.
  3. If the condition returns true, go to step 4. Otherwise, execute the next line following the end of the do while loop.
  4. Go back to step 1.

In the following example, the do while loop is executed till the value of the variable x is less than 10.

x=1
do{
trace(”X is equal to ” +x); // output: 1,2,3,4,5,6,7,8,9
x++ // same as x = x + 1
}while(x<10)

Click here to download 9A0-058 test study guide and practice question. Pass Macromedia Flash Professional in first attampt.
Like this article? Share it with others
If you like this article, please leave a comment or subscribe this blog via RSS or via e-mail, Bookmark and share through your network. Click the AddThis button below. Thanks.
  • Share/Bookmark
Advertisement

Leave a Reply

uCertify.com | Our Company | Articles | Contact Us | News and Press Release | uCertify India | Entries (RSS)
MCSE: MCSA, MCTS, MCITP    JAVA Certification: SCJP, SCWCD    Cisco Certification: CCNA, CCENT    A+, Network+, Security+ Project+
Oracle Certification: OCP 11g, OCP 10g, OCA 11g, OCA 10g    CIW foundation    EC-212-32,    CISSP    Photoshop ACE CS4    Adobe Flash ACE, PMP, CAPM
© 2008 uCertify.com. All rights reserved. All trademarks are the property of their respective owners.