1. recursive definition function

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

2. Did you miss this post?

3. thanks for the advice hammer i am new here as you can se

4. >constant expression required

C90 does not support variable-length arrays. The diagnostic message means the following.
Code:
```int n = 5;
long sequence[n+1]; /* illegal, but... */
long seq[6]; /* ... this is ok */```
Searching for 'fibonacci' and 'recursion' -- both here and on Google -- ought to turn up numerous examples of a recursive fibonacci function.

5. many thanks i'll try a loop

6. many thanks i'll try a loop