0

I don't understand why my program executes both case 0 and case 1 when N =0 is entered by user

https://code.sololearn.com/cO7VZXTr828T/?ref=app

20th Apr 2018, 2:12 PM
Jules SG
Jules SG - avatar
3 Antworten
+ 1
The statement break; is missing to close the instructions inside every case. switch(variable) { case 0: std::cout << "It's zero"; break; case 1: std::cout << "It's one"; break; default: std::cout << "None of them"; } Please note that break; statement must not be added to the default setion.
20th Apr 2018, 2:18 PM
Luigi
Luigi - avatar
+ 1
Thank you!
20th Apr 2018, 2:43 PM
Jules SG
Jules SG - avatar
0
No problem! 👍
20th Apr 2018, 2:50 PM
Luigi
Luigi - avatar