- Posts: 1
- Joined: Sun Jun 07, 2020 3:28 pm
for( int i = 0; i< 0; i++) x = 3; is said to be a correct option, however later it says
"for( int i = 0; false; i++) x = 3; is also a compile time error because x= 3 is unreachable."
It seems like it is impossible to correctly answer this question.
- Site Admin
- Posts: 9169
- Joined: Fri Sep 10, 2010 9:26 pm
Option 4 i.e. for( int i = 0; i< 0; i++) x = 3; is correct because it will compile without any error.
The explanation talks about unreachable code and then shows a variation of option 4, which fails compilation because of this issue. for( int i = 0; false; i++) x = 3; is not same as the statement in option 4.
We will enhance the explanation to make this clear.
Users browsing this forum: No registered users and 1 guest