0
How does the logic in For loops work in C# ?
Here is the code for(int i =1;i <=5;i++) { for(int j =5;j >=i;j--) { Console.Write(j) ; } Console.WriteLine(); } The output will be 54321 5432 543 54 5 So, my qoustion is why the code still doing loop when int j >= i (2 >= 4)at 4th line. In my logic when 2>=4 the loop will only print the console.writeline() ; I hope you understand my code and my english. Thanks in advance.
2 Answers
+ 3
On each iteration of i, the "j-loop" is entered anew. Look at int j = 5: j will always be resetted to 5 on each "i-interation"
0
Thank you