+ 2

What's wrong with this code

#include <iostream> using namespace std; int main() { money; cin >> money; switch(money){ case(money >> 100): cout << "You're almost poor"; break; case(money << 100): cout << "You're poor"; break; cout << "Thanks for participating"; } return 0; }

9th Apr 2018, 5:00 AM
sovietcat
sovietcat - avatar
6 Respostas
+ 5
I've debugged the code for you as corrected by Timon Paßlick #include <iostream> using namespace std; int main() { int money; cin >> money; if (money > 100) cout << "You're almost poor"; else cout << "You're poor"; cout << "Thanks for participating"; return 0; }
9th Apr 2018, 5:56 AM
Rusty.Metal
+ 4
You forgot an int: int money; You can't use switch here, it's just to compare with single values, not expressions. Use if instead. It's not >> 100 and << 100, it's > 100 and < 100.
9th Apr 2018, 5:04 AM
Timon Paßlick
+ 2
Happy to help :) Zexery
9th Apr 2018, 5:57 AM
Rusty.Metal
+ 1
@name
9th Apr 2018, 7:02 AM
Timon Paßlick
0
Thanks alot @Rusty
9th Apr 2018, 5:56 AM
sovietcat
sovietcat - avatar
0
wtf how do you link my name like that
9th Apr 2018, 6:17 AM
sovietcat
sovietcat - avatar