C program to understand for loop

      No Comments on C program to understand for loop

C for loop is used when you know how many times you want statement or a block of statements to be executed.

SYNTAX:-

for (initialization; condition; increment)
{
    code to be executed;
}

1.Initialization: Initialize the loop counter value. For example: i=1; .

2.Condition: Condition is evaluated for each loop iteration. If it evaluates to TRUE, the loop continues. If it evaluates to FALSE, the loop ends. For example: i<=10; .
3.Increment:Increase the loop counter values. For example: i++ ;.

EXAMPLE:-

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

OUTPUT:-

scanfcode

Leave a Reply

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