loop

This is a discussion on loop within the C Programming forums, part of the General Programming Boards category; HI!..this is a question about the following loop. we can see 2 loops here. for(i=0;i<10;i++) { STATEMENTS #1; for(j=0;j<10;j++) //inner ...

  1. #1
    Registered User
    Join Date
    Aug 2002
    Posts
    4

    Wink loop

    HI!..this is a question about the following loop.
    we can see 2 loops here.

    for(i=0;i<10;i++)
    {

    STATEMENTS #1;


    for(j=0;j<10;j++) //inner loop

    {

    If(j==5)
    break;

    } //inner loop


    STATEMENTS #2;
    }

    Here when we break from the inner loop,, Does it continue in the inner loop or goes to statements#2 in outer loop?.

    Thanks
    Mur3

  2. #2
    Registered User
    Join Date
    Mar 2002
    Posts
    64
    Hi
    Try this code and you will get your answer..
    It will go to statement #2

    Code:
    #include <stdio.h>
    #include <conio.h>
    
    
    int main()
    {
         int i, x;
         clrscr();
         for(i=0; i<11; i++)
         {
              printf("The number is now: %d\n", i);
              if(i==5)
              {
    	for(x=0; x<5; x++)
    	{
     	     printf("Now I'm inner Loop nr %d\n",x);
    	     if(x==4)
    	     break;
    	}
              printf("Hi, I'm out now\n");
              }
         }
         getch();
         return 0;
    }
    !G!

  3. #3
    mur3
    Guest

    Thumbs up

    thanks bud!...

    Murshid..

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. nested loop, simple but i'm missing it
    By big_brother in forum C Programming
    Replies: 19
    Last Post: 10-23-2006, 11:21 PM
  2. While loop misbehaving (or misunderstanding)
    By mattAU in forum C Programming
    Replies: 2
    Last Post: 08-28-2006, 03:14 AM
  3. loop in a linked linked lists
    By kris.c in forum C Programming
    Replies: 6
    Last Post: 08-26-2006, 01:38 PM
  4. while loop help
    By bliznags in forum C Programming
    Replies: 5
    Last Post: 03-20-2005, 12:30 AM
  5. loop issues
    By kristy in forum C Programming
    Replies: 3
    Last Post: 03-05-2005, 09:14 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21