Advertisement
Advertisement
/* C - Break statement example */
#include<stdio.h>
int main() /* main method starts */
{
for(int i=0;i<10;i++)
{
if(i==5)
break; /* when i is equal to 5, break statement takes the control out of loop */
printf("i = %d \n",i);
}
printf("Out of the loop");
return 0;
} /* main method ends and so does the program */
i = 0
i = 1
i = 2
i = 3
i = 4
Out of the loop
Advertisement
Advertisement
Please check our latest addition
C#, PYTHON and DJANGO
Advertisement