Break und Continue
By Matthias Fechner
Code
#include <stdio.h>
/* Programm to use break and continue
to break loops
*/
int main(void) {
int i,j;
for(i=0;i<10;i++) {
if(i>3)
continue;
printf("i=%d\n",i);
}
for(j=0;j<3;j++) {
printf("j=%d\n",j);
for(i=0;i<100;i++) {
if(i>1)
break;
printf("i=%d\n",i);
}
}
return 1;
}
Result
~/c_tutor> gcc break_continue.c idefix@idefix_mobil
~/c_tutor> ./a.out idefix@idefix_mobil
i=0
i=1
i=2
i=3
j=0
i=0
i=1
j=1
i=0
i=1
j=2
i=0
i=1