Thread: Evaluation of nested loops

  1. #1
    CS Author and Instructor
    Join Date
    Sep 2002

    Evaluation of nested loops

    Hello, All

    Another semester is upon us. I will teach C Programming at my college again this semester (as well as Java and C++)

    I am looking for tips and tricks to show my students how to evaluate nested loops like

    for (etc,,)
    for (etc)

    I like to show how the code actually does work by tracing throught the code. AS you know it can get confusing quickly.

    I thought somewhere here or on another board someone posted a good shortcut for evaluating nested loops.

    I have tried google. Not much there to help.

    Thanks for the ideas Mr. C
    Mr. C: Author and Instructor

  2. #2
    Gawking at stupidity
    Join Date
    Jul 2004
    Oregon, USA
    You mean you want something like:
    int main(void)
      int i, j;
      for(i = 0;i < 5;++i)
        for(j = 0;j < 5;++j)
          printf("%d %d\n", i, j);
    ? I'm confused as to what you're looking for.
    If you understand what you're doing, you're not learning anything.

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    Well iterating through all the elements of a 2D array (or a matrix) is one example
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Nested loops
    By zeondik in forum C# Programming
    Replies: 2
    Last Post: 10-26-2008, 06:58 AM
  2. nested for loops
    By akub3 in forum C Programming
    Replies: 2
    Last Post: 04-01-2004, 06:21 AM
  3. nested for loops and bank account interest help!!
    By webvigator2k in forum C++ Programming
    Replies: 1
    Last Post: 04-07-2003, 08:03 PM
  4. Output from nested loops
    By IzaakF in forum C Programming
    Replies: 2
    Last Post: 09-01-2002, 06:09 AM
  5. nested for loops
    By Unregistered in forum C Programming
    Replies: 4
    Last Post: 11-17-2001, 11:44 AM