Passing the test task:
Using the ternary operator, replace the initialization of the variable
bin the specified code:
int a = 10; int b; if (a > 0) { if (a < 100) { b = 1; } else { b = 0; } } else { b = -1; } In my opinion, here it is necessary to use an embedded ternary operator, I did this:
int a = 10; int b; b = (a > 0) ? ((a < 100) ? b = 1 : b = 0) : b = -1 ; but the test answers that I'm wrong. Where am I wrong and why is this so?
b = ...? b=1 : b=2b = ...? b=1 : b=2, butb=...? 1 : 2b=...? 1 : 2- andy.37