i am writing a small prog which will return thr nth term of the fibonacci
but keep getting
constant expression required
any help would be great
#include<stdio.h>
#include<math.h>
#include<conio.h>
main();
// function fibonacci(int)
/**
* long fibonacci(int n)
* Returns the nth term in a
* Fibonacci sequence.
* Parameters:
* n - an integer >= 0.
* Return value:
* long - The Fibonacci value of the nth term
* (-1 for illegal input).
*/
long fibonacci(int n)
{
if ( n < 0 )
return -1;
if ( n == 0 || n == 1 )
return 1;
long sequence[n+1]; // constant expression required //
sequence[0] = 1;
sequence[1] = 1;
for ( int i = 2; i <= n; i++ )
sequence[i] = sequence[i-2] + sequence[i-1];
return sequence[n];
}