This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

For loop

can i use the for loop like this in accessing the 2-d array.

   for(u=0;u<=4;u++)
     {
       for(v=v1;;)
          {
             arr[u][v] += 1;
           }
     }

bcos in the second for loop i want to do the increment in some other function.

but the c51 shows an endless loop on executing the second for loop.

can i use only one for loop and no for loop for v since this v i want to increment in some other function?

Parents
  • "can i do the increment of the 'y' of arr[x][y] in another function?"

    Of course you can!

    I think you need to go back to your 'C' textbook, and thoroughly read the description of the 'for' loop, and precisely what the 3 expressions in the 'for' clause actually do...

    for( w=0; x<y; z++ )
    {
       :
       :
    }
    


    is equivalent to

    for( w=0; x<y;  )
    {
       :
       :
       z++;
    }
    

Reply
  • "can i do the increment of the 'y' of arr[x][y] in another function?"

    Of course you can!

    I think you need to go back to your 'C' textbook, and thoroughly read the description of the 'for' loop, and precisely what the 3 expressions in the 'for' clause actually do...

    for( w=0; x<y; z++ )
    {
       :
       :
    }
    


    is equivalent to

    for( w=0; x<y;  )
    {
       :
       :
       z++;
    }
    

Children