Break (out of loop)
The break statement causes an immediate exit from the innermost while, do while, for, and switch statements.
Example:
for(i = 1, i <= 10; i++) {
printf("%d\n", i);
if (i == 3)
break;
printf("bottom of loop\n");
}
printf("out of loop\n");
The output is
1
bottom of loop
2
bottom of loop
3
out of loop
This example on page 114.
Previous slide
Next slide
Back to first slide
View graphic version