Pages

Adhexa

Tuesday, August 17, 2010

while statement

The while statement is the simplest loop statement in any programming language. Typically, a while loop look like this:

while(condition){
body/statement
}

The while loop works like this. The condition in the parentheses is first tested. If it is true then the body(or statement) of the loop is executed. The condition is tested again and if true, the body of the loop is executed again. This goes on as long as the condition is true. The loop terminates if the condition is false and the statements after the while loop are executed.

No comments:

Post a Comment