## naya22 14

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?

## iamthwee 1,547

Did you write that yourself?

## naya22 14

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

## iamthwee 1,547

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.

## naya22 14

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.

## jimmymerchant

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!

## naya22 14

So, how do I get the user to specify the value of N??

## ndeniche 402

this way:

``````int 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...

## anupam_smart 2

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