Nested for loop and break : For Break « Language Basics « C / ANSI-C






Nested for loop and break

  
#include <stdio.h>

int main(void)
{
  int i, j;

  for( i = 0; i < 5; i++) {
    for(j = 0; j < 100; j++) {
      printf("%d", j);
      if(j == 5) 
          break;
    }
    printf("\n");
  }

  return 0;
}

           
       








Related examples in the same category

1.indefinite loop and break
2.Break a infinite loop
3.Use break to terminate a for loop
4.Use break in for loop to exit