CodesJava

Easy learning with example program codes

C while loop


C While Loop is a loop statement which can be used in various forms to execute a block of code continuously as long as the condition of the loop is true, and stops only when the condition fails. These are:

While Loop :

While loop is used to execute a group of action as long as the specified condition is true.

Syntax:

while (condition)

{

            code to be executed if the condition is true;

}

 Nested While Loop :

Nested While loop is While loop inside a While loop and so on which is used to run multiple loop conditions.

Syntax:

while (condition)

{

while (condition)

{

                        code to be executed if the condition is true;

}

}

Infinitive While loop :

Infinitive While loop is a While loop with condition 1 and thus running for infinite number of times.

Syntax:

while (1)

{

code to be executed;

}

 

Example of While loop

#include <stdio.h>
 
void main()
{
int i = 1;
 
while (i <= 10)
{
printf ("%d", i);
printf ("\n");
i++;
}
}

Output

1
2
3
4
5
6
7
8
9
10
Posted in C   
Sign Up/ Sign In
Ask a Question


Industrial Training

We offers Placement Oriented Training on Java, Spring, JSF, Hibernate, PHP, AngularJS, Angular 4, PLSQL, Oracle BI Publisher etc. We also provides Online training, please mail us at hr@codesjava.com.

Development

We also provides the Development services for Website Development , Java Development, PHP Development, Android App Development etc. You can contact us on hr@codesjava.com.

Copyright © 2018 CodesJava DMCA.com Protection Status SiteMap Reference: Java Wiki