+ 2

Code coach (Gotham City)

Please guys what is wrong with my code? #include <iostream> using namespace std; int main() { int x=10; if(x<5){ cout <<"I got this!"; } if(x>=5&&x>=10){ cout <<"Help me Batman"; } else{ cout <<"Good Luck out there"; } return 0; }

30th Apr 2020, 12:34 PM
Neba Emmanuel
Neba Emmanuel - avatar
3 Respostas
+ 2
I think you mistyped >= instead of <= in the second condition when checking 'x' against ten. Also, the entire if-statement should be an if - if else - else - statement, otherwise two clauses will be executed instead of one, because the first if currently is independant from the second. Furthermore, 'x' should be taken as input, not initialized to ten from the start. You should also check if all the output phrases are correct according to the exercise description.
30th Apr 2020, 12:43 PM
Shadow
Shadow - avatar
0
It works now bro, thanks
30th Apr 2020, 1:39 PM
Neba Emmanuel
Neba Emmanuel - avatar
0
My code #include <iostream> using namespace std; int main() { int b; cin>>b; if (b<5){ cout << "I got this!"; } if (b>5 && b==10){ cout << "Help me Batman"; } if (b>10){ cout << "Good Luck out there!"; } if (b==5){ cout << "Help me Batman"; } return 0; }
30th Jun 2020, 3:55 PM
Тимофей Орловский