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
4 Réponses
+ 1
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
0
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
0
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
0
Ok thanks guys
23rd Jul 2025, 12:48 PM
Alban
Alban - avatar