0

Digital manu

Why my code is not right, need help, thanks The code: #include <iostream> using namespace std; int main() { string menu[] = {"fruits", "chicken", "fish", "cake"}; try { int x; cin >> x; //your code goes here switch (x) { case 0: cout << "fruits"; break; case 1: cout << "chicken"; break; case 2: cout << "fish"; break; case 3: cout << "cake"; break; } if (x!=0 && x!=1 && x!=2 && x!=3){ throw 404; } } catch(int x) { //and here cout << x << "- not found"; } }

27th Dec 2020, 2:07 PM
Zhilin Hu
3 Respostas
0
What's the problem statement ?
27th Dec 2020, 2:13 PM
Hima
Hima - avatar
0
the out put was not the expected, and code couldn’t go through
27th Dec 2020, 2:20 PM
Zhilin Hu
0
#include <iostream> using namespace std; int main() { string menu[] = {"fruits", "chicken", "fish", "cake"}; try { int x; cin >> x; //your code goes here if (x >= 0 && x <= 3){ cout << menu[x] << endl; } else{ throw 404; } } catch(int x) { //and here cout << x << " - not found" << endl; } } I hate the fact that sololearn does not include answer. we are learning not working.
23rd Dec 2021, 12:11 AM
Brian H
Brian H - avatar