break statement: break, exit do, exit for, exit while, last

used for the immediate interruption of the loop. after execution, will proceed with the following command after loop.

break

Description

break ;
Used keywords: break
compatible programing languages:
C | Visual C++ .NET | C++ | C# | Java | JavaScript | PHP

Examples

Example

even one example in what situations we can use the operation break statement:
i=10;
do --i; while ( i > 0);
do {
  i++;
  if (i==5)
    break;
} while ( i <10);

Example

Other pieces of example codes:
if (i==10)
     break;
   else 
   {
     i--;
   }
if (i==10)
     break;
   else 
   {
     i--;
   }
if (i==3)
    break;

exit do

Description

exit do
Used keywords: do exit
compatible programing languages:
Basic | FreeBASIC | Visual Basic .NET

Examples

Basic

even one example in what situations we can use the operation break statement:
i=10
do
 i=i-1
 loop while i > 0
do
  i=i+1
  if i=5 then
    exit do
end if
loop while i <10

Basic

Other pieces of example codes:
if i=10 then
     exit do
   else
     i=i-1
   end if
if i=10 then
     exit do
   else
     i=i-1
   end if
if i=3 then
    exit do
end if

exit for

Description

exit for
Used keywords: exit
Note: usable in the following locations:

compatible programing languages:
Basic | FreeBASIC | Visual Basic .NET

Examples

Basic

even one example in what situations we can use the operation break statement:
i=10
do
 i=i-1
 loop while i > 0
do
  i=i+1
  if i=5 then
    exit do
end if
loop while i <10

exit while

Description

exit while
Used keywords: while exit
compatible programing languages:
Basic | Visual Basic .NET

Examples

Basic

even one example in what situations we can use the operation break statement:
i=10
do
 i=i-1
 loop while i > 0
do
  i=i+1
  if i=5 then
    exit do
end if
loop while i <10

last

break

Description

break ;
Used keywords: break
compatible programing languages:
Pascal | Object Pascal | Free Pascal

Examples

Object Pascal

even one example in what situations we can use the operation break statement:
i:=10;
repeat dec(i) until not i > 0;
repeat
  inc(i);
  if i=5 then
    break;
until not i <10;

Object Pascal

Other pieces of example codes:
if i=10 then
     break
   else 
   begin
     dec(i)
   end
if i=3 then
    break;
Languages: en hu cz sk