+ 1
Why my program for fibonicci series is giving error?
4 Antworten
+ 4
It was because the compiler could not decide whether it will be initialized.
If there is a possibility that initialization will not be performed by a branch such as if statement, a compile error occurs.
+ 4
Because you haven't initialised (a) and( b) . Do this
int a=0,b=0,c;
Dont know about Fibonacci series but whats happening here is that the input goes to last else where it says c=a+b since you never put any value to a and b , so it shows error .
It should be initialised differently for Fibonacci but thats what is causing the error .
+ 2
But in for loop, if(i==0) needs to be executed first, that initialise the value of a.
+ 1
It means i have to initialise a and b at the time of declaration i.e int a=0,b=1. Hm, i got it. Thanks all.