#include <iostream>
using namespace std;
int main ()
{
int i=400;
do
{
i++;
cout<<"before the break\n";
break;
cout<<"after the break,should never print\n";
}
while(i<3);
cout<<"after the do loop\n";
system("pause");
return 0;
}
the output of this code:
before the break
after the do loop
my question is why the sentence "before break" is printed although the while statement is <3 ?
#include <iostream>
usingnamespace std;
int main ()
{
int i=400;
do
{
cout << i << endl;
i++;
cout << i << endl;
cout<<"before the break\n";
break;
cout<<"after the break,should never print\n";
}
while(i<3);
cout << i << endl;
cout<<"after the do loop\n";
system("pause");
return 0;
}