+ 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++?
2 odpowiedzi
+ 12
answer: else if
syntax:
if(condition){
//statements;
}
else if(condition){
//statements;
}
+ 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");