Thread: void fibonacci() - Is This Possible?

  1. #1
    Not Yet
    Guest

    void fibonacci() - Is This Possible?

    I'm trying to work on a project that deals with Fibonacci numbers, but the recursive function for fibonacci is void so I can't figure out how to work it. I have to add the code in the if/else statements in the function fibonacci.

    This is the code:

    Code:
    class fibon
    {  unsigned int prev1,    // f(n-1)
    		prev2;    // f(n-2)
     public:
       fibon()
       {}
       void fibonacci(unsigned int month);
    };
    
    void fibon::fibonacci(unsigned int month)
    { unsigned int fib;
    
      if (month == 0)
      {
      }
      else if (month == 1)
      {
      }
      else
      {
      }
      *xout << setw(13) << month << setw(16) << fib << endl;
      if (xout == &sout && month == 22)  // Stop scrolling.
      {  cout << "Press enter to continue.";
         cin.ignore(80,'\n');
         //delline();
    } }
    Is this possible, if so, can you just point me in the right direction.

  2. #2
    Not Yet
    Guest
    Nevermind, I figured it out.

  3. #3
    Registered User
    Join Date
    Jan 2002
    Posts
    552
    assuming each instance of the fib class is suppose to solve the fib problem, create instances that solve smaller fib problems and use those instances to solve the bigger problem (same basic idea as recursion)
    C Code. C Code Run. Run Code Run... Please!

    "Love is like a blackhole, you fall into it... then you get ripped apart"

  4. #4
    Registered User
    Join Date
    Jan 2002
    Posts
    552
    C Code. C Code Run. Run Code Run... Please!

    "Love is like a blackhole, you fall into it... then you get ripped apart"

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Another syntax error
    By caldeira in forum C Programming
    Replies: 31
    Last Post: 09-05-2008, 01:01 AM
  2. How to better manage large .cpp files
    By 39ster in forum C++ Programming
    Replies: 6
    Last Post: 08-25-2008, 08:24 AM
  3. get keyboard and mouse events
    By ratte in forum Linux Programming
    Replies: 10
    Last Post: 11-17-2007, 05:42 PM
  4. need help with handelling multiple source files
    By DarkMortar in forum C++ Programming
    Replies: 38
    Last Post: 05-26-2006, 10:46 PM
  5. Error, not sure what it means.
    By RealityFusion in forum C++ Programming
    Replies: 1
    Last Post: 09-25-2005, 01:17 PM