Advertisement
Advertisement
// C++ break statement example
#include<iostream>
int main() // main method starts
{
for(int i=0;i<10;i++)
{
if(i==6)
break; // when i is equal to 6, break statement takes the control out of loop
cout<< "i = " << i << "\n";
}
printf("And, we are out of the loop");
return 0;
} // main method ends and so does the program
i = 0
i = 1
i = 2
i = 3
i = 4
i = 5
And, we are out of the loop
Advertisement
Advertisement
Please check our latest addition
C#, PYTHON and DJANGO
Advertisement