Nested if statements without parentheses

the following code is given:

if (c2-c1==0) if ( c1 != c3 ) {...} 

How to interpret this code? The first if-statement comes without {}. Is the code above equal to the following code ?:

  if (c2-c1==0){ if ( c1 != c3 ) {...} } 
+4
source share
3 answers

Yes. The if statement applies to the next statement after it - which is different if in this case.

+5
source

Yes they are equivalent

+3
source

That's right. A room without brackets means that the only command in the first case, if another, if, which can contain everything you want.

+1
source

Source: https://habr.com/ru/post/921492/


All Articles