while loop in C
A while loop statement in C programming language repeatedly executes a target statement as long as a given condition is true.
Syntax:
The syntax of a while loop in C programming language is: Diagram:
Here, key point of the while loop is that the loop might not ever run. When the condition is tested and the result is false, the loop body will be skipped and the first statement after the while loop will be executed.
Example:
#include <stdio.h> int main () { /* local variable definition */ int a = 10; /* while loop execution */ while( a < 20 ) { printf("value of a: %d\n", a); a++; }