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

28th Oct 2019, 8:35 AM
VISHAL JAYMANGAL DEDAVAT
2 Antworten
+ 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.
28th Oct 2019, 9:06 AM
HonFu
HonFu - avatar
+ 3
What's with the downvote?
28th Oct 2019, 9:23 AM
HonFu
HonFu - avatar