+ 2

Simple question

In Python, if we want multiple statements but only one can be true we use elif. What is the equivalent of elif (python) in C++?

5th Mar 2018, 12:41 PM
Marin
Marin - avatar
2 odpowiedzi
+ 12
answer: else if syntax: if(condition){ //statements; } else if(condition){ //statements; }
5th Mar 2018, 12:48 PM
Hannah Grace
Hannah Grace - avatar
+ 3
In C/C++ there isn't a dedicated "elif" so we simply use an else followed by an if. For example.. if(bacon_is_good) printf("Awesome\n"); else if(eggs_are_good) printf("Also Awesome\n"); else printf("Not cool\n");
5th Mar 2018, 12:46 PM
Lewis
Lewis - avatar