About if & if else statement

What is the dffrense between

 
  if{

&
 
 else if{

???
They're branching statements that are usually seen together. Only difference is, you can declare if statements all by their lonesome, whereas with else if, you need a previously declared if.

In terms of pseudocode, it goes like
1
2
3
4
5
6
if this condition happens
    do this
else if another condition happens
    do that
else // for literally any other case that might happen that's not covered by the previous statements
    do another thing
Technically else if is not a separate construch, but just another if in the else statement:

YFGHNG example is parsed as:
1
2
3
4
5
6
7
8
9
if this condition happens {
    do this
} else { 
    if another condition happens {
        do that
    } else { // for literally any other case that might happen that's not covered by the previous statements
        do another thing
    }
}
Thank u
closed account (48T7M4Gy)
Choice between two options

1
2
3
4
if (...)
   this
else
   that


Choice between more than two options (by nesting)

1
2
3
4
5
6
7
8
if (...)
   this
else if (...)
   that
else if (...)
   whatever
else
   at last

Topic archived. No new replies allowed.