C++ examples for Statement:break
Break out of for loop with if and break statement
#include <iostream> using namespace std; int main()/* w ww .ja va 2s . c om*/ { int i; for (i=0; i<10; i++) { cout << i << " "; if (i == 5) { break; } cout << i * 2 << endl; } cout << "All Finished!" << endl; return 0; }