For Loop Statement in C Programming

This is an entry controlled looping statement.
In this loop structure, more than one variable can be initialized. One of the most important feature of this loop is that the three actions can be taken at a time like variable initialization, condition checking and increment/decrement. The for loop can be more concise and flexible than that of while and do-while loops.

Syntax:

for(initialization; test-condition; incre/decre)
{
	statements;
}

In above syntax, the given three expressions are seperated by ‘;’ (Semicolon)

Features :
o More concise
o Easy to use
o Highly flexible
o More than one variable can be initialized.
o More than one increments can be applied.
o More than two conditions can be used.

Program :

/*  Program to demonstrate for loop.
Creation Date : 09 Nov 2010 02:52:31 PM
Author :www.technoexam.com [Technowell, Sangli] */

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

int main(void)
{
	int i;
	clrscr();
	for(i=0; i<5; i++)
	{
		printf("\n\t TechnoExam");  // 5 times
	}
	getch();
	return 0;
}

Output :


	TechnoExam
	TechnoExam
	TechnoExam
	TechnoExam
	TechnoExam_

Leave A Comment

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