for statement syntax C sharp 1

for statement syntax C sharp

//this loop will repeat 4 times
for(int i=0; i<4; i++)
{
 //do something 
}

Here is what the above code is Doing:
1. The for loop starts with the keyword for.
2. The for loop has a variable i that is initialized to 0.
3. The for loop has a condition that says to continue looping as long as i is less than 4.
4. The for loop has a statement that says to increment i by 1 each time the loop runs.
5. The for loop has a block of code that is executed each time the loop runs.

Similar Posts