What are the differences between nested if and &&?

c, if-statement

Solution

The differences are mainly in readability and maintenance.

Concatenation of 2 logical conditions should usually imply that there is a semantic relation between them.

Another thing to consider is the scoping. The nested `if` gives you additional flexibility in this area.

Problem

What are the differences between writing: ``` if(condition1 && condition2){ //some code } ``` And: ``` if(condition1){ if(condition2){ //some code } } ``` If there are any, which one is better?

Original source