Doubt about IF statement [SOLVED]

Is there any difference between

if (main condition) {
if (1st condition) { 
do something... 
} else if (2nd condition) {
do something...
}
}

and this:

if (main condition) {
if (1st condition) {
do something...
}
if (2nd condition) {
do something...
}
}

between using only if's or if and if else's..

Thanks in adance!

Yes. The 2nd do something will be run for 1st condition and 2nd condition being true for the second example, but not for the first.

Sorry but i couldn't understand

Yes there is a difference, it depend what you want to do.

In the first case, the "else if" will be checked only if the first "if" condition wasn't true. In the second case, both conditions will be checked.

So for example in this case:

if ( a == 2 )
  // do something

if ( a == 3 )
  // do something else

it is better to use a "else if".

But in this case for example:

if ( a == 2 )
  // do something

if ( b == true )
  // do something unrelated to the first condition

Using a "else if" here, will not be what you want the program to do

i got it! many thanks for your help!

Cheers