0
Can someone tell me what's my mistake here? c++
int x = (rand() % 12); switch (x) { case (1 || 2 || 3 || 4): cout << "petra" << endl; break; case (5 || 6 || 7 || 8): cout << "psalidi" << endl; break; case (9 || 10 || 11 || 12): cout << "xarti" << endl; break; // it tells me that i defined 2 times the same case
2 Respuestas
+ 4
Hey, a switch case should look somthing like this
switch(x){
case 1:
statement;
break;
default:
statement;
}
I think you might like this 😏
switch(x) {
case 1:case 2:case 3:case 4:{
//your statement goes here
}
case 5:case 6:case 7:case 8:{
//your statement goes here
}
default;
//your statement goes here
}
+ 1
What do you want to get from this code?