views:

51

answers:

3

Hi,

following code is given:

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

How do I 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 )
                {...}
 }
+3  A: 

Yes, they are equivalent

Armen Tsirunyan
+4  A: 

Yes. The if statement applies to the next statement after it - which happens to be another if in this case.

xscott
+1  A: 

Absolutely. Putting no brackets means that the only instruction in the first if is the other if, which can contains anything you want.

LucaB