Question: I'm writing a C program that calculates a specific number in the fibonacci sequence, though I'm having trouble returning the sequence as an array....

What am I doing wrong?

```

int fibonacci(int ceiling)
{
  int counter;
  int num1 = 1, num2 = 1;
  static int fibArray[1000];
  for (counter = 1; counter < ceiling; counter+=2)
    {
      fibArray[counter] = num1;
      fibArray[counter+1] = num2;
      num2 += num1;
      num1 += num2;
    }
  return &(fibArray);
}

```

I also get the error:

```

fibonacci.c:28: warning: return makes integer from pointer without a cast

```

?

Answer: 
You don't need an array. You just need two integers in which you hold current value and previous value. You then make:

```
newValue = previousValue + newValue;
previousValue = newValue - previousValue;`

```

and you should be set. When the limit is being hit, just return the newValue.

If you do want to return the whole array (you are saying "calculates a specific number in the fibonacci sequence" which is not the whole sequence). Make the return type of your function int\* and use the array.
```
//you dont need all the "includes" I have in here. These are just a basic format I work with. This should get you going if you arent going already. cheers. :) 

#include<iostream>
#include<cstdlib>
#include<iomanip>
#include<cmath>
#include<stdio.h>
#include<cctype>
#include<list>
#include<string>

using namespace std;
int main()
//-------------------------------declaration of variables----------------------------------
{
   int num1, num2;
   int initial_value, final_value;
//-----------------------------------------inputs------------------------------------------
   cout << "What is your first number? :";
   cin  >> num1;
   initial_value = num1;
   cout << "What is your second number? :";
   cin >> num2;
   final_value = num2;
//-----------------------------------------dasloop----------------------------------------
   do
   {
       final_value = initial_value + final_value;
       initial_value = final_value - initial_value;
       cout  <<  final_value  <<  endl;
   }
   while(final_value <= 1000);

//---------------------------exits perfectly when greater than 1000------------------------
   cout << endl << endl;
   system("pause");
   return 0;
}
//I have it exit at 1000 because its a nice round number that allows you enough room
//to see the code, and sequence are both correct. 

```