4
Contributors
5
Replies
6
Views
4 Years
Discussion Span
Last Post by MandrewP
0

Are you asking about something like this?

if(something)
{
    if(somethingelse)
    {
        //...
    }
    else
    {
        //...
    )
}
else
{
    if(somethingelse)
    {
        //...
    }
    else
    {
        //...
    }
}
0

oops i forgot to add else:

if (test)
{
    if (another_test)
    {
        ...
    }
    else
    {
        ...
    }
    ...
}
else
{
    ...
}
0
  if(true)
      do_this;
   else if(true)
      do_this;
   else if(true)
      do_this;
   else if(true)
      do_this;
   else if(true)
      do_this;

This is called a decesion tree, and only one if statement will execute out of the whole bunch. When one of the if statements does execute, then control drops out to the bottom bypassing all the other remaining if statements.

Actually, they are not called else-if statements but rather they are the regular if-else statements just written that way for clarity.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.