While loop in c with example

While loop is simplest loop in c

Syntax:-

while(condition)
{
Body of the loop
}
Statement;

Note:-

# If body of loop is only one statement than braces ({}) are not needed.
# Body of the loop may have one or more statement.

Execution:-

In while loop 1st condition will check if condition is true than body of the loop will executed. After body of the loop is execute, the condition is again tested if condition is true than again body of loop is executed, this process is repeated until condition is true. When condition is false than statement next to while loop is executed.

Example:-

Program to count N numbers


Program to display even number up to 20





Previous Code:-
for loop

List Code:-
C Codes

Next Code:-
do-while loop

C Programs
List of c Programs

Leave reply

Add your comments here

Back to Top