For Loop
The for loop contains three parts: initialization,
conditional expression, and steps, which are separated by a semicolon,
1. variable initialization:
Declare & initialize a variable here which will be used in conditional expression
and steps part.
2.
condition:
The condition is a boolean expression that will return either true or false.
3.
steps: The
steps define the incremental or decremental part
Syntax
for ( initialization;
termination; increment/decrement)
{
statements
}
|
For Loop example
class ForLoopExampleProgram
{
static void Main(string[] args)
{
int i;
i = 1;
for (i = 0; i <= 50; i++)
{
Console.WriteLine("current Value of
the i variable is :" + i.ToString());
i = i + 5;
}
Console.Read();
}
|