logoISU  

CS256 - Principles of Structured Design

Fall 2021

Displaying ./code/cs256su21code/jun07/loop4.c

#include <stdio.h>

int main()
{
	
	int i;
	// This will only print the numbers 3 through 6:
	for(i=0; i < 10; i++) {
  		if (i < 3) continue;  // If i < 3 go immediately to the increment-expression
  		if (i > 6) break;     // When i reaches 7 (i.e. > 6) exit the loop.
  		// Only when i passes the above two checks does this statement run:
  		printf("%d\n", i);
	}	

	// i will be == 7 here, since the for loop exited early.
	printf("i = %d\n", i);
	return 0;
}