While Loop in C Programming

This is an entry controlled looping statement. It is used to repeat a block of statements until condition becomes true.

Syntax:

while(condition)
{
	statements;
	increment/decrement;
}

In above syntax, the condition is checked first. If it is true, then the program control flow goes inside the loop and executes the block of statements associated with it. At the end of loop increment or decrement is done to change in variable value. This process continues until test condition satisfies.

Program :

/*  Program to demonstrate while loop.
Creation Date : 09 Nov 2010 03:45:01 AM
Author : www.technoexam.com [Technowell, Sangli] */

#include <stdio.h>
#include <conio.h>

int main(void)
{
	int a;
	clrscr();
	a=1;
	while(a<=5)
	{
		printf("\n TechnoExam");
		a+=1;      // i.e. a = a + 1
	}
	getch();
	return 0;
}

Output :

 TechnoExam
 TechnoExam
 TechnoExam
 TechnoExam
 TechnoExam_

Leave A Comment

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