+ 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; } }
6 ответов
+ 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;
}
+ 13
P.S. Don't forget to mark the best answer with the new update:
https://www.sololearn.com/discuss/285782/?ref=app
+ 4
cout <<"one more line"<<endl;
+ 3
Thank you :)
+ 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;
}
+ 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.