Statement
break;causes the innermost loop (or switch) that contains it to stop, and causes the program to move to just after that loop or switch. For example, suppose that you have a function isPrime(n) that yields true if integer n is prime and false if not. Then the following function returns the smallest prime number that is greater than n.
long nextPrime(long n)
{
long i;
for(i = n+1; ; i++)
{
if(isPrime(i))
{
break;
}
}
return i;
}