Q:

Break Statement in Loops

What does break; do in the following code? I basically need to go out of the inner loop, but continue the outer loop
for(i=0;i<n;i++)
{
    for(j=i;j<n;j++)
    {
        if(condition)   
        {   
          count++;
          break;
        }
    }

}

A:

The break in your code will break out of the inner loop.Then the outer loop continues(if the condition in it is true) just as you want. Note that break has no effect on ifs. It will break out of loops like for,while etc and when it is placed inside nested loops as the one you have,it will break out of the inner-most loop only.

