- 1
I'm confused
I was wondering what would happen if: int a = 2 ; for(a=3;;); Console.WriteLine(a) I've learned that for loop does instructions as follows: 1)It proceeds with first instruction 2)Then it checks the condition (the first semicolone) 3)If true proceeds with second instruction (second semicolone) 4)Otherwise if false breaks out of the loop and continues with code My idea was that the value would now be 3 but this is not the case.It turns out that there is an error that says"Unreachable code" Why?
5 Answers
0
well you've created an infinite code. a is set as 3, but then there's no condition to check for, so since it'll always be true, the code will be stuck in the for loop forever.
0
System.out.println(3);?
- 1
So how do i get the value 3 on the screen?
- 1
in c#
- 1
Oh yeah pretty simple thanks for all help