Syntax :
while( condition )
{
statement(s);
}
Example :
#include <stdio.h>
int main ()
{
// local variable definition
int a = 1;
// while loop execution
while( a < 5 )
{
//loops comes inside this body, until condition is true
printf("Value of a: %d\n", a);
a++;
}
return 0;
}
Output :
Value of a: 1 Value of a: 2 Value of a: 3 Value of a: 4
No comments:
Post a Comment