0

What is wrong with that code please help me I can't figure out

https://sololearn.com/compiler-playground/cwHaCiEelzQ6/?ref=app

23rd Jul 2025, 11:30 AM
Alban
Alban - avatar
10 ответов
0
What did he said ?
23rd Jul 2025, 5:00 PM
Alban
Alban - avatar
+ 4
Bhushan kale keep your language clean on Sololearn. Personal attacks are unacceptable and will get your account banned.
23rd Jul 2025, 3:36 PM
Brian
Brian - avatar
+ 3
There are two problems with your code. The `return 0;` statement returns a value from the function(in this case, main()) and stops the function. Also, you need to wrap your conditions inside these brackets– ( ) Here is the fixed, working code ``` #include <iostream> using namespace std; int main() { // remove return 0 from here int points; cin>>points; cout << points; if (points<20) { // wrap your condition in parenthesis cout << "Tu as rouge."<<endl; } return 0; // putting it here ensures all code runs before termination } ``` You might want to use `cout <<points << endl;` for better formatting
23rd Jul 2025, 12:03 PM
Vaibhav
Vaibhav - avatar
+ 3
other than being written the wrong way, (most people would put the >= on the left and the <= on the right of &&), your conditions are mostly inverted. also, else does not accept any condition. #include <iostream> using namespace std; int main() { int points; cin>>points; cout <<points <<" points."; if(points>=0 && points<=19) { cout << "Tu as rouge."<<endl; } else if (points>=20 && points<=39){ cout << "Tu as jaune."<<endl; } else if (points>=40 && points<=59){ cout << "Tu as vert pale."<<endl; } else if (points >=60 && points<=79){ cout << "Tu as vert."<<endl; } else if (points>=80 && points<=99){ cout << "Tu as vert +."<<endl; } else{ cout << "Tu ment on peut pas avoir plus de 100 points."<<endl; } return 0;}
23rd Jul 2025, 3:03 PM
Bob_Li
Bob_Li - avatar
+ 2
don't put return 0; on the beginning. it will cause main() to exit immediately. if conditions are enclosed in parenthesis if (points<20) #include <iostream> using namespace std; int main() { // return 0; ❌ wrong int points; cin>>points; cout << points; if (points<20) { ✅ use ( ) cout << "Tu as rouge."<<endl; } return 0; ✅ put return 0; here }
23rd Jul 2025, 11:45 AM
Bob_Li
Bob_Li - avatar
+ 2
As the code evolves, errors evolve too. Keep trying! Errors are a constant companion to developing code - even for professional programmers. Though you corrected the above problems, new changes added another. The latest problem is that the less-than-or-equal comparison operator is mistyped. It should be <=, not =<.
23rd Jul 2025, 1:30 PM
Brian
Brian - avatar
+ 1
The code has minor error you need to write return 0; line below if statement and in if statement you need to add common brackets inside the condition Like this below #include <iostream> using namespace std; int main() { int points; cin>>points; cout << points; if (points<20) { cout << "Tu as rouge."<<endl; } return 0; }
23rd Jul 2025, 11:43 AM
Aysha
+ 1
Please I got another problem and I don't understand it
23rd Jul 2025, 2:17 PM
Alban
Alban - avatar
+ 1
Thanks
23rd Jul 2025, 3:30 PM
Alban
Alban - avatar
0
Ok thanks guys
23rd Jul 2025, 12:48 PM
Alban
Alban - avatar