Geeks With Blogs
Stephanie Grima C#, ASP.NET and my life.

DO/WHILE Statement


So people may ask: What is the difference between a while loop and a do while loop?
  • The difference is that the do... while has the expression in the bottom of the loop. This means that he code has to be executed AT LEAST, ONCE.
  • The while statement on the other side, is not executed at all if the condition is false from the beginning.

This is how a do while looks:
do {
statement/s
} while (expression);


A more real example is the following:

int counter = 1;
results = "";
do
{
results + = "Count is: " + counter;
count++;
} while (counter <= 11);
Posted on Wednesday, October 29, 2008 9:14 PM C# , Java | Back to top


Comments on this post: [C#] [Java] Control Structures Part 4 : DO/WHILE Statement

No comments posted yet.
Your comment:
 (will show your gravatar)


Copyright © Steffi | Powered by: GeeksWithBlogs.net