OCJP

Using While Loop in C Language

Loops are used to execute repeated statements. While is a simple loop (iteration) that is used like

while(condition)
{
}

Execution of any loop depends on three points.

  • Initial value of variable
  • Condition of loop
  • Change in variable (increment/decrements)
#include<stdio.h>
#include<conio.h>
void main()
{
	int i=100; //Initial Value
	clrscr();

	while(i<=200) //condition
	{
	printf("%d ",i);
	i+=10;// change in variable
	}
getch();
}

Output

100 110 120 130 140 150 160 170 180 190 200

Leave a Reply

Your email address will not be published. Required fields are marked *


× How can I help you?