Break a for loop : break « Operators statements « C++ Tutorial






#include <iostream> 
using namespace std; 
 
int main() 
{ 
  int t; 
 
  // Loops from 0 to 9, not to 100! 
  for(t=0; t<100; t++) { 
    if(t==10) break; 
    cout << t << ' '; 
  } 
 
  return 0; 
}
0 1 2 3 4 5 6 7 8 9








3.18.break
3.18.1.Break a for loop
3.18.2.Break an infinite loop
3.18.3.Break from while
3.18.4.Demonstrating a Forever Loop