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

C++ Programming

Thread Tools
 
Search this Thread
 
  #21  
Old 03-30-2006, 06:17 PM
Sanguinius's Avatar
Super Moderator
Join Date: Mar 2005
Location: Norfolk, VA
Posts: 4,864
Default RE: C++ Programming

Nah cuz I still don't know shyt lol
 
  #22  
Old 03-30-2006, 06:21 PM
mysterio2099's Avatar
Thread Starter
Join Date: Nov 2005
Location:
Posts: 836
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

 
  #23  
Old 03-30-2006, 08:05 PM
Sanguinius's Avatar
Super Moderator
Join Date: Mar 2005
Location: Norfolk, VA
Posts: 4,864
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...
 
  #24  
Old 03-30-2006, 08:10 PM
mysterio2099's Avatar
Thread Starter
Join Date: Nov 2005
Location:
Posts: 836
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

 
  #25  
Old 03-30-2006, 08:39 PM
Sanguinius's Avatar
Super Moderator
Join Date: Mar 2005
Location: Norfolk, VA
Posts: 4,864
Default RE: C++ Programming

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

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

 
  #27  
Old 03-30-2006, 09:31 PM
Sanguinius's Avatar
Super Moderator
Join Date: Mar 2005
Location: Norfolk, VA
Posts: 4,864
Default RE: C++ Programming

Jeezus lol
 
  #28  
Old 03-31-2006, 10:50 AM
TheEngineer's Avatar
Super Moderator
Join Date: Jan 2006
Location:
Posts: 11,758
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]
 
  #29  
Old 03-31-2006, 10:58 AM
mysterio2099's Avatar
Thread Starter
Join Date: Nov 2005
Location:
Posts: 836
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?

[:-]

 
  #30  
Old 03-31-2006, 05:11 PM
EMonz57's Avatar
Senior Member
Join Date: 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??!!??
 


Quick Reply: C++ Programming



All times are GMT -5. The time now is 01:43 AM.