I was just curious about the else if
statement in C so I looked at the C99 standard and found nothing. Then I looked at the grammar but again no else if
selection_statement
: IF '(' expression ')' statement
| IF '(' expression ')' statement ELSE statement
| SWITCH '(' expression ')' statement
;
How is the else if
declared in C. By reading the standard, how can I notice it is part of it?
The
else if
statement is officially defined as byproduct of theif
statement in §6.8.4/1, C18 by declaring the syntax:The last "statement" in the latter form describes that another
if
statement can be followed after anelse
.Beside that, you can find an, of course non-normative, example of its use in the C standard in normative appendix G in the code example at G.5.1/8:
This is the only place where an
else if
statement appears as it is in the C18 standard.So regarding:
There at least although examples are non-normative it is part of it.