0
I don't understand why my program executes both case 0 and case 1 when N =0 is entered by user
3 Respuestas
+ 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.
+ 1
Thank you!
0
No problem! 👍