I have a question about for loop; Code is below
for (int i = 0; i <= 3; i++)
{
for (int j = 0; j < 2; j++)
{
Console.WriteLine("J");
}
Console.WriteLine("I");
}
Output of this code is;
J J I J J I J J I J J I
My question is : at first for loop "i" is 0 and condition is true so, loop goes to second loop j is 0 and condition is true. It writes "J", then j++ is working and now J is 1. Second loop is writing "J" again and then increase it to 2 so second for loop condition is false and it goes to first for loop, It writes "I" and then increases the first loop i is 1 right now so first for loop condition is true and it goes second one: Question starts here. J was 2, how is the J went 0 after first loop condition true again and write 2 J again?
I hope I can tell you my problem properly. Thank you so much