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"; } }
3 Respostas
0
What's the problem statement ?
0
the out put was not the expected, and code couldn’t go through
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.