0

Can we use such conditions in switch statements?

int y; cin>>y; switch (y) { case 1||2||3|| : cout<<"great"; break; default: cout<<"oh no!"; } 🤔🤔

27th Sep 2018, 5:07 PM
Mubarak Hussain
Mubarak Hussain - avatar
2 Respuestas
+ 2
Place the case in sequential lines as follows: int y; cin >> y; switch (y) { case 1: case 2: case 3: cout << "great"; break; default: cout << "oh no!"; }
27th Sep 2018, 5:50 PM
Ipang
+ 1
Nope!
27th Sep 2018, 5:37 PM
Dipendra Shrestha
Dipendra Shrestha - avatar