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 cout << Fibonacci(n-1) + Fibonacci(n-2); statement is. It is telling me that it is a call of nonfunction.

What am I doing wrong here?

Recommended Answers

All 9 Replies

Member Avatar for iamthwee

Did you write that yourself?

I'm sorry...It's not really my program.

Member Avatar for iamthwee

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.

okay, okay, don't get hostile. I'll try it myself and come back. I really do apologize though, for trying to take the easy way out.

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, how do I get the user to specify the value of N??

this way:

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;
}

hope u don't mind i used ur code jimmymerchant...

but that's the way it will work with an user input...

Well,
What's gonin' on here guys..
I thought the rule here is to correct an existing code instead of providing a completly new one.
-Must take care of this...
Thanks

sorry about that... :D

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.