While Loop In C



while loop may be used where we don’t know how many times loop must be run.


Syntax of while loop in c


initilization;

while(condition)

{

Statement;

incr/decr;

}


Print Codeverb.com message for 5 times by using while loop


#include <stdio.h>

#include<conio.h>

void main(){

{

int i;

i=1;

clrscr();

while(i<=5)

{

printf(“Codeverb.com %d\n”,i);

i++;

}

getch();

}



Output:
Codeverb.com 1
Codeverb.com 2
Codeverb.com 3
Codeverb.com 4
Codeverb.com 5