eugene eugene - 2 months ago 20
C++ Question

c++ continue versus break

Which statement will be executed after "continue" or "break" ?

for(int i = 0; i < count; ++i)
{
// statement1
for(int j = 0; j < count; ++j)
{
//statement2
if(someTest)
continue;
}
//statement3
}

for(int i = 0; i < count; ++i)
{
// statement1
for(int j = 0; j < count; ++j)
{
//statement2
if(someTest)
break;
}
//statement3
}

Answer

continue: ++j and then if j < count then statement2 otherwise statement3

break: statement3