While loop in C
×


While loop in C

107

 A while loop in C repeats block of code as long as a condition remains True.

The loop is executed until the condition becomes false.

The loop is started with the while keyword.

 Inside the parentheses (), you provide a condition that decides whether the loop should continue repeating or stop.

 If the condition is true, the loop continues executing.

 If the condition is false, the loop stops executing and the program moves on to the next line of code after the loop.

The block of code inside the curly braces is '{ } ' body of the loop.

It contains the instructions that are executed repeatedly.

After each execution of loop, the condition is checked again. If it is still true the condition continues; otherwise the loop get terminated.

Using while loop you can create a programs that perform repetitive tasks efficiently and flexibly.

While Loop Execution 

while loop Syntax in C Language 

while(condition){
// block of code to be repeated
}
Example:

#include<stdio.h>
int main()
{
	int A = 5;
	while(A <=10){
	printf("%d\n", A);
	A++;
	}
	return 0;
}

Output:

5
6
7
8
9
10


Best WordPress Hosting


Share:


Discount Coupons

Get a .COM for just $6.98

Secure Domain for a Mini Price



Leave a Reply


Comments
    Waiting for your comments