Off Topic A place for you car junkies to boldly post off topic. Almost anything goes.

C++ Programming

Thread Tools
 
Search this Thread
 
Old Mar 30, 2006 | 06:17 PM
  #21  
Sanguinius's Avatar
Super Moderator
Joined: Mar 2005
Posts: 4,874
From: Norfolk, VA
Default RE: C++ Programming

Nah cuz I still don't know shyt lol
 
Old Mar 30, 2006 | 06:21 PM
  #22  
mysterio2099's Avatar
Thread Starter
Joined: Nov 2005
Posts: 836
From:
Default RE: C++ Programming

lol. I'm trying to figure out this one program I was shown the code to write.. I understand all but one part.. basically what it does is calculate the nth number in the Fibonacci series.

For those who don't know, the Fibonacci series is just taking the two previous numbers and adding them to get the new number, starting with 1,1 ... so, it goes like this:

1,1,2,3,5,8,13....

In this program, you can input 4, to find what the 4th number in the series would be... which comes out to be 3.

...only problem is I don't understand part of the code, so I'm stumped. lmao

 
Old Mar 30, 2006 | 08:05 PM
  #23  
Sanguinius's Avatar
Super Moderator
Joined: Mar 2005
Posts: 4,874
From: Norfolk, VA
Default RE: C++ Programming

K what code do you have so far? And how exactly are they writing out the code? There are various ways to go about doing this...
 
Old Mar 30, 2006 | 08:10 PM
  #24  
mysterio2099's Avatar
Thread Starter
Joined: Nov 2005
Posts: 836
From:
Default RE: C++ Programming

I figured it out. Here's the code though:

Code:
 7:     #include <iostream.h>
 8:
 9:     int fib(int n);
 10:
 11:    int main()
 12:    {
 13:
 14:      int n, answer;
 15:      cout << "Enter number to find: ";
 16:      cin >> n;
 17:
 18:      cout << "\n\n";
 19:
 20:      answer = fib(n);
 21:
 22:      cout << answer << " is the " << n << "th Fibonacci number\n";
 23:         return 0;
 24:    }
 25:
 26:    int fib (int n)
 27:    {
 28:      cout << "Processing fib(" << n << ")... ";
 29:
 30:      if (n < 3 )
 31:      {
 32:         cout << "Return 1!\n";
 33:         return (1);
 34:      }
 35:      else
 36:      {
 37:        cout << "Call fib(" << n-2 << ") and fib(" << n-1 << ").\n";
 38:        return( fib(n-2) + fib(n-1));
 39:      } 
 40: }
Lines 1-6 were comments.

I put 100 into the program and it ran for 40 minutes before I had to shut my computer down and leave work, hahahahaha

 
Old Mar 30, 2006 | 08:39 PM
  #25  
Sanguinius's Avatar
Super Moderator
Joined: Mar 2005
Posts: 4,874
From: Norfolk, VA
Default RE: C++ Programming

Shoulda left it run see if it woulda had an answer for you tommorrow or something LOL
 
Old Mar 30, 2006 | 08:42 PM
  #26  
mysterio2099's Avatar
Thread Starter
Joined: Nov 2005
Posts: 836
From:
Default RE: C++ Programming

a friend ran it.. its been going for an hour and a half now.

 
Old Mar 30, 2006 | 09:31 PM
  #27  
Sanguinius's Avatar
Super Moderator
Joined: Mar 2005
Posts: 4,874
From: Norfolk, VA
Default RE: C++ Programming

Jeezus lol
 
Old Mar 31, 2006 | 10:50 AM
  #28  
TheEngineer's Avatar
Super Moderator
Joined: Jan 2006
Posts: 11,758
From:
Default RE: C++ Programming

ok this is just annoying...if you are going to have a conversation just appove the damn things...[sm=headbang.gif]
 
Old Mar 31, 2006 | 10:58 AM
  #29  
mysterio2099's Avatar
Thread Starter
Joined: Nov 2005
Posts: 836
From:
Default RE: C++ Programming

LOL, who put me back on P/A?? Patrick told me he was taking me off yesterday... didn't know anyone could over rule the big dawg?

[:-]

 
Old Mar 31, 2006 | 05:11 PM
  #30  
EMonz57's Avatar
Senior Member
Joined: May 2005
Posts: 12,084
Default RE: C++ Programming


ORIGINAL: mysterio2099

LOL, who put me back on P/A?? Patrick told me he was taking me off yesterday... didn't know anyone could over rule the big dawg?

[:-]

I took you off the other day and now someone put it back, and Patrick and I talked and about it as well... maybe he didnt nitice I removed it and he added it back on??!!??
 



All times are GMT -5. The time now is 04:46 AM.