Please support our C advertiser: Programming Forums
Views: 2178 | Replies: 9
![]() |
I am having problems generating the Fibonacci sequence. I would like to start at 30.
Here is my program:
#include <iostream>
#include <conio>
using namespace std;
int main()
{
int Fibonacci, n;
cout <<"Here is the Fibonacci number sequence until 30 .";
if ( n==1 || n==2 )
return( 1 );
else
cout << Fibonacci(n-1) + Fibonacci(n-2);
getch();
return 0;
}
However, I am getting an error message where the statement is in bold. It is telling me that it is a call of nonfunction.
What am I doing wrong here?
Here is my program:
#include <iostream>
#include <conio>
using namespace std;
int main()
{
int Fibonacci, n;
cout <<"Here is the Fibonacci number sequence until 30 .";
if ( n==1 || n==2 )
return( 1 );
else
cout << Fibonacci(n-1) + Fibonacci(n-2);
getch();
return 0;
}
However, I am getting an error message where the statement is in bold. It is telling me that it is a call of nonfunction.
What am I doing wrong here?
Wanna know how I knew that. You have a function but with no actual declaration of it. (no Sh*t sherlock!)
Word of advice. Don't try cheating. Try it yourself from the beginning. You'll get a lot more out of it.
Word of advice. Don't try cheating. Try it yourself from the beginning. You'll get a lot more out of it.
Last edited by iamthwee : Apr 8th, 2007 at 11:08 am.
... the hat of 'is this a cat in a hat?'
•
•
Join Date: Apr 2007
Posts: 3
Reputation:
Rep Power: 0
Solved Threads: 0
hey its easy to generate a fib series, it just adds the prev 2 nos and then get the third one.
so u cud have for loop to generate it as follows
for(j=0;j<30;j++)
{temp=temp+temp+1)
}
//this generates the fib series till 30
for(i=temp;i<n;i++)
{
i=i+i+1;
printf("%d",& num)
}
// this will generate the remaining fib series from 30 onwards until where u want thats by specifying the value of n!
so u cud have for loop to generate it as follows
for(j=0;j<30;j++)
{temp=temp+temp+1)
}
//this generates the fib series till 30
for(i=temp;i<n;i++)
{
i=i+i+1;
printf("%d",& num)
}
// this will generate the remaining fib series from 30 onwards until where u want thats by specifying the value of n!
this way:
hope u don't mind i used ur code jimmymerchant...
but that's the way it will work with an user input...
c Syntax (Toggle Plain Text)
int N; cout<<"Please input n"; cin>>N; for(j=0;j<N;j++){ temp=temp+temp+1) }for(i=temp;i<n;i++){ i=i+i+1; cout>>num; }
but that's the way it will work with an user input...
-->sometimes i wanna take my toaster in a bath<-- ![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)






Linear Mode