What am i doing wrong? :( | Sololearn: Learn to code for FREE!
Nouvelle formation ! Tous les codeurs devraient apprendre l'IA générative !
Essayez une leçon gratuite
+ 3

What am i doing wrong? :(

#include <iostream> using namespace std; int main() { return 0; } { int x=10; while (x<20) { cout "One more line" endl; int x=x+1; } while (x=20) { cout "stop"; int x=30; } }

30th Mar 2017, 7:21 PM
Nightshot
6 Réponses
+ 15
Quite a few things: int main() { int x=10; while (x<20) { cout <<"One more line" <<endl; x=x+1; } while (x=20) { cout "stop"; x=30; } return 0; }
30th Mar 2017, 7:29 PM
Jafca
Jafca - avatar
+ 13
P.S. Don't forget to mark the best answer with the new update: https://www.sololearn.com/discuss/285782/?ref=app
30th Mar 2017, 7:32 PM
Jafca
Jafca - avatar
+ 4
cout <<"one more line"<<endl;
30th Mar 2017, 7:24 PM
Pat.Fischer91
Pat.Fischer91 - avatar
+ 3
Thank you :)
30th Mar 2017, 7:30 PM
Nightshot
+ 1
#include <iostream> using namespace std; int main () { int x=10; while(x<20) { cout << "One more line" << endl; x=x+1; } while (x=20) { cout "stop"; x=30; } } return 0; }
30th Mar 2017, 7:29 PM
Pat.Fischer91
Pat.Fischer91 - avatar
+ 1
I'm not C++ expert by a long shot. I think you should start by putting the code into the main function. As it is now, the compiler has no idea what you're doing because your code isn't between anything. It needs to be in its own function or in the main function. While shouldn't be used like that. While is used for repeating statements. Use an if statement instead.
30th Mar 2017, 7:30 PM
Trevor Brick
Trevor Brick - avatar