Showing posts with label FOR LOOP in C. Show all posts
Showing posts with label FOR LOOP in C. Show all posts

Tuesday, 31 January 2012

Program Of For LOOP in C


#include<stdio.h>
#include<conio.h>
main()
{
int i;
clrscr();
printf("\n================== Ascending Order========================\n");
{
printf("\n %d",i);
}
printf("\n================== Descending Order========================\n");
for(i=10;i>=1;i--)
{
printf("\n %d",i);
}

getch();
}

----------------------------------------------------------------------

In computer science a for loop is a programming language statement which allows code to be repeatedly executed. A for loop is classified as an iteration statement .
There are three parts that are separated by semi-colons in control block of the Cfor loop.
initialization_expression is executed before execution of the loop starts. The initialization_expression is typically used to initialize a counter for the number of loop iterations. You can initialize a counter for the loop in this part.
The execution of the loop continues until the loop_condition is false. This expression is checked at the beginning of each loop iteration.
The increment_expression, is usually used to increase (or decrease) the loop counter. This part is executed at the end of each loop iteration.