QUOTE(sdasin4 @ 25 Oct, 2006 - 11:19 PM)

i was asked to generate upto n-terms of fibonacci series using recursive function in C PROGRAM. I WROTE the following PROGRAM FOR IT:
CODE
main()
{
int n,f;
lrscr();
printf("enter any number limit");
scanf("%d",&n);
f=fibo(n);
printf("\n%d",f);
getch();
}
fibo(int n)
{
if(n==0||n==1)
return 1;
else
{
fibo(n)=fibo(n-1)+fibo(n-2);
return n;
}
}
when i COMPILED THE ABOVE WRITTEN PROGRAM IT SHOWED:
L VALUE REQUIRED
WHAT'S THIS L VALUE THING?
CAN ANY1 CAN HELP ME OUT PLSSSSSSSS.
'COZ OF THIS L VALUE PROBLEM I CAN'T RUN THE PROGRAM.
HELP ME POT PLSSSSS.
WILL BE REALLLLLY grateful
THX. in advance
Hi
I guess the first thing is to find out what an L VALUE is... in your code
fibo(n)=fibo(n-1)+fibo(n-2); there is an equal sign....
Guess what... LVAL = RVAL... that is one meaning of L VALUE... all it means is you have a binary (takes two arguments) operator with one value on the left and one on the right. Other operators that are binary like = include +, -, /, * and %. Just swap the operator for the = in LVAL = RVAL (eg LVAL % RVAL).
Now.. to the problem at hand...
fibo(n) is a function.. and you want to deal with integers... because the type "pointer to a function" is not an integer, you are getting an L Value required error...
hope this helps