for loop inside of a for loop

This is a discussion on for loop inside of a for loop within the C++ Programming forums, part of the General Programming Boards category; 3 E i=1 (4 E j=1 (i+j)) 3 is number on top i=1 is number on bottom then the entire ...

  1. #1
    pippen
    Guest

    for loop inside of a for loop

    3 E i=1 (4 E j=1 (i+j))
    3 is number on top
    i=1 is number on bottom
    then the entire other loop is that thing you gotta get

    How would I do that in C++?

    Thanks.

  2. #2
    Registered User
    Join Date
    Mar 2003
    Posts
    20
    I have no idea what you're asking, but you put a for loop inside a for loop like this:

    Code:
    for(i = value; i < anotherValue; i++)
    {
         for(e = value; e < anotherValue; e++)
         {
              //do stuff
          }
    }

  3. #3
    pippen
    Guest
    I tried this:

    for(i=1; i<=3
    {
    for(j=1; j<=4; (i+j))
    {
    cout<<i<<endl;
    }

    }


    but it keeps scrolling down 1's when I execute it...any more suggestions?

  4. #4
    Registered User
    Join Date
    Nov 2002
    Posts
    1,109
    you need to update j in the second loop. (i+j) doesn't do anything, try j += i . you also need to update i in the first loop.

  5. #5
    Registered User
    Join Date
    Mar 2003
    Posts
    20
    for(i=1; i<=3; i++)
    {
    for(j=1; j<=4; j+=i)
    {
    cout<<i<<endl;
    }

    }

  6. #6
    pippen
    Guest

    Thumbs up

    Thanks!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. call to realloc() inside a function: memory problem
    By simone.marras in forum C Programming
    Replies: 15
    Last Post: 11-30-2008, 10:01 AM
  2. declaring variables inside loops
    By samus250 in forum C Programming
    Replies: 21
    Last Post: 04-30-2008, 02:51 PM
  3. variables when declared inside or outside a function
    By jas_atwal in forum C Programming
    Replies: 6
    Last Post: 12-14-2007, 02:42 PM
  4. Still battling with Copy Control
    By Mario F. in forum C++ Programming
    Replies: 9
    Last Post: 06-23-2006, 09:04 AM
  5. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 07:39 AM

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