0

I don't get whats wrong. Is there someone that can help me?

#include <iostream> #include <fstream> using namespace std; int main(){ int z; char x; int y; cin >> y; cin >> x; cin >> z; switch (x){ case '+': cout << y + z; case '-': cout << y - z; case '/': cout << y / z; case '*': cout << y * z; break; } return 0; }

31st Jul 2016, 8:44 PM
Shadi Vandeventer
Shadi Vandeventer - avatar
2 Réponses
+ 1
You must break; at the end of each case. Not at the end of the switch statement. Other than that, I don't see anything else wrong.
31st Jul 2016, 9:14 PM
Cohen Creber
Cohen Creber - avatar
0
a switch case doesn't work with char because it can't compare the two values
31st Jul 2016, 10:48 PM
bogdan
bogdan - avatar