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(const long n) { long i; for(i = n+1; ; i++) { if(isPrime(i)) { break; } } return i; }
Caution. You can use break to break out of any kind of loop. But it does not work to get out of a function. For that, use return.