#include<iostream.h>
#include<conio.h>
main()
{
clrscr();
int i;
for(i=2; i<100; i+=2)
{
cout<<"\n"<<i;
}
getch();
}
----------------------------------------------------------------------
for(startExpression; testExpression; countExpression)
{
block of code;
}
The startExpression is evaluated before the loop begins. It is acceptable to declare and assign in the startExpression(such as int x = 1;). This startExpression is evaluated only once at the beginning of the loop.
The testExpression will evaluate to TRUE (nonzero) orFALSE (zero). While TRUE, the body of the loop repeats. When the testExpression becomes FALSE, the looping stops and the program continues with the statement immediately following the for loop body in the program code.

No comments:
Post a Comment