Thread: Recursive

  1. #1
    Registered User
    Join Date
    Aug 2009
    Posts
    10

    Recursive

    Code:
    int main()
    {  
         recurse(5,3);
         return 0;
    } // end main
    void recurse(int x, int y)
    {     if (y > 0)
         {     ++x;
                --y;
                cout <<  x << " " <<  y  << endl;  
                recurse(x, y);
                cout <<  x << " " <<  y << endl;  
          }  // end if
    }  // end recurse
    What is the output?

  2. #2
    Jack of many languages Dino's Avatar
    Join Date
    Nov 2007
    Location
    Chappell Hill, Texas
    Posts
    2,332
    Did you not run it?
    Mainframe assembler programmer by trade. C coder when I can.

  3. #3
    Unregistered User Yarin's Avatar
    Join Date
    Jul 2007
    Posts
    2,158
    We give up. But if you don't know, and want to, then download and install GCC, the GNU Compiler Collection - GNU Project - Free Software Foundation (FSF) and Code::Blocks, then build, link, and run the program, and you have your answer.

  4. #4
    Call me AirBronto
    Join Date
    Sep 2004
    Location
    Indianapolis, Indiana
    Posts
    195
    6 2
    7 1
    7 1
    6 2

  5. #5
    Registered User
    Join Date
    Apr 2006
    Posts
    2,149
    Quote Originally Posted by Yarin View Post
    We give up. But if you don't know, and want to, then download and install GCC, the GNU Compiler Collection - GNU Project - Free Software Foundation (FSF) and Code::Blocks, then build, link, and run the program, and you have your answer.
    There is an easier way
    It is too clear and so it is hard to see.
    A dunce once searched for fire with a lighted lantern.
    Had he known what fire was,
    He could have cooked his rice much sooner.

  6. #6
    Registered User jeffcobb's Avatar
    Join Date
    Dec 2009
    Location
    Henderson, NV
    Posts
    875
    Again? Is he trying to pass a class w/o running a compiler? Neat trick if you can do it...
    C/C++ Environment: GNU CC/Emacs
    Make system: CMake
    Debuggers: Valgrind/GDB

  7. #7
    Unregistered User Yarin's Avatar
    Join Date
    Jul 2007
    Posts
    2,158
    Quote Originally Posted by King Mir View Post
    Cool, thanks for the link. Neat idea.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. recursive function
    By technosavvy in forum C Programming
    Replies: 1
    Last Post: 02-29-2008, 05:42 AM
  2. difference between recursive and iterative
    By Micko in forum C Programming
    Replies: 33
    Last Post: 07-06-2004, 09:34 PM
  3. Algorithm help (Changing from Recursive to Non Recursive)
    By Thantos in forum C++ Programming
    Replies: 1
    Last Post: 04-25-2004, 07:27 PM
  4. Request for comments
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 01-02-2004, 10:33 AM
  5. How to change recursive loop to non recursive loop
    By ooosawaddee3 in forum C Programming
    Replies: 1
    Last Post: 06-24-2002, 08:15 AM