EnggPedia - The Engineering Encyclopedia

Wed03292017

Last update06:04:15 AM

Font Size

Profile

Menu Style

Cpanel
Back Computer Programming Languages While Loop & Do-While Loop - Definition & Syntax

While Loop & Do-While Loop - Definition & Syntax

While Loop:

While loop is a conditional loop which execute set of instructions repeatedly until specific condition remains true. The general syntax of while loop is

While (condition)

Statement (s);

In syntax of while loop, while is keyword. The symbol ; will not used at the end of while statement because it is a control structure. If you have more than one statement in statement (s) block of while loop, then all instruction should be placed in { }.

Do- while Loop:

do- while loop is also a conditional loop which execute set of instructions repeatedly until specific condition remain true. The general syntax of do- while loop is

do

{

Statement (s) ;

}

While( condition);

In syntax of do- while loop, do and while are keywords. The symbol ; will be used at the end of while statement because it is not following by body of loop. If you have one or more than one statements in statement (s) block of while loop, then always enclose all instructions within { }.

Related Articles to this Article
While loop is a conditional loop which execute set of instructions repeatedly until specific condit
The most common advantages of C language are
In C/ C++ language, loop is an iterative constructs which execute set of instructions according to
Input functions or streams are used are to read different type of data (Such as numeric, string or
Read more similar Articles