for (int i = 0; i < 10; i++)
{
Console.WriteLine("Value of i: {0}", i);
}
for (initializer; condition; iterator)
body
//Example :
for (int i = 0; i < 5; i++)
{
Console.WriteLine(i);
}
//int i = 0 -- Making variable i
//i <=10 -- Making a condition for the loop to keep going
//i++ -- Increasing i by 1
for(int i = 0; i <= 10; i++)
{
Console.Write(i+1);
}
/*
Output:
12345678910
*/
for (int i = 0; i < 5; i++)
{
Console.WriteLine(i);
}
______________OUTPUT____________
0
1
2
3
4
for (int i = 0; i < 5; i++)
{
Loop
}
for (int i = 0; i < 5; i++)
{
if (i >= 4)
{
break;
}
Console.WriteLine(i);
}
for(i = 2; i < 100; i*=2)
{
Console.Write(i + " ");
}
Console.Readkey();
for(int i = 0; i < 3; i++)
{
}
for(int i = 0; i < 3; i++) // output:
{ // Hi
Console.WriteLine("Hi"); // Hi
}
{
int[] luckyNumbers = { 4, 8, 15, 16, 23, 42 };
for (int i = 0; i < luckyNumbers.Length; i++)
Console.WriteLine(luckyNumbers[i]);
}
Console.ReadLine();
for(int i = 0; i<5; i++)
{
//commands
}
for(int i = 0; i < 10; i++)
{
print(i+5);
}
for (int i = 0; i < 5; i++)
{
//looping stuff
}
for (initializer; condition; iterator)
body
for(int i = 0, i < p, i++){}