I was trying to implement Fibonacci but I am getting unexpected values.What am I doing wrong ?

```
//Fibonacci
#include <iostream>
using namespace std;
int calfib(int n,int memo[]);
int fib(int n)
{
int i,memo[n];
for(int i = 0 ; i < n ;i++)
{
memo[i] = -1;
}
memo[0] = 0;
memo[1] = 1;
return calfib(n,memo);
}
int calfib(int n, int memo[])
{
if(memo[n] != -1)
return memo[n];
else
{
return (calfib(n-2,memo) + calfib(n-1,memo));
}
}
int main()
{
cout << fib(8) << endl;
}
```