0
All else statement must have corresponding if statement . Does this mean that no of if in else must be equal to no of else in if
2 Réponses
+ 4
This is about C++, right?
An if can stand alone, it doesn't need an else.
But every else needs an if.
if(whatever) {
do_one_thing();
} else {
do_another_thing();
}
The else is connected to the if.
Now if you wrote another else, it wouldn't be clear to what it is related, since the first else and if are connected - the second else would be isolated.
+ 3
What's with the downvote?