+ 1
#include <iostream> using namespace std; int main() { for (int x=1; x<10; x++) { if (x==2){ continue; } if (x==5){ break; } cou
How many numbers will the following above loop output?
12 Respostas
+ 7
1. Your code is incomplete.
2. You can run it yourself in the code playground, and verify the result.
0
cou?
0
Alex Boso Nzaphila
As Tibor suggested, if you ran the code in playground you would have the answer to your question.
0
Continue; omits the following statement
Break; immediately exits the statement where it is
0
If you add a line like
cout<<x<<endl;
Then you'll get the output like:
1
3
4
0
for(int x=1;x<10;x++) {
if(x == 2) {
continue;
}
if(x == 5) {
break;
}
cout << x << endl;
}
0
5
- 1
cout<<x<<endl;
}
}
- 1
It's not supposed to be run, its a question asked.
- 1
It's incomplete code, so how it would be declare loop output.
- 1
Three if we don't look at the syntax mistakes :)
- 1
Thanks Rob