While Loop

I'm not clear on the While Loop. Is it evaluated only at the beginning of each loop or continuously? If I'm evaluating a switch condition and I have five lines of conditional code following, will I possibly jump out after 2 or three lines are completed or is it always an integral number of times through the loop. I don't want to leave this block part way through an execution of this block.

Dave

while (condition)
    {
    statement1;
    statement2;
    statement3;
    }

is functionally equivalent to:

label1:
if (!(condition)) goto label2;
statement1;
statement2;
statement3;
goto label1;
label2:

There is also a DO-WHILE which guarantees that the body gets executed at least once:

do
    {
    statement1;
    statement2;
    statement3;
    }
while (condition);

is functionally equivalent to:

label1:
statement1;
statement2;
statement3;
if (condition) goto label1;

@Stolfa

I made a program using 2 while() loop. Check my code and up-dated code at this link. http://arduino.cc/forum/index.php/topic,73670.0.html

@johnwasser

That is a good explaination and analogy of while() { } and do { } while() in BASIC I assume XD

Techone:
in BASIC I assume XD

Nope, as shown in the Arduino sketch below. There is seldom a reason to use labels or goto statements but they are legal C and C++ constructs.

void setup(){}
void loop()
{
  boolean condition;

// In the form of a 'while' loop
  while (condition)
    {
    statement1();
    statement2();
    statement3();
    }

// The equivalent of a 'while' loop
label1:
  if (!(condition)) goto label2;
  statement1();
  statement2();
  statement3();
  goto label1;
label2:;
}

void statement1(){}
void statement2(){}
void statement3(){}

@johnwasser

Ok, I get it. I read it in the C++ book "C++ for Dummies".