Fibonacci Check

I am writing code to check if a given number is a part of the fibonacci sequence. However , after setting up the while loop for the fibonacci sequence and inputting the value of the given number , the code always gives me output that the given number is a part of the fibonacci sequence.

@aryanpandeya
You are checking it incorrectly. First of all take input of k before you run the loop. Secondly , print the message of not in Fibonacci series after the loop gets over in case it was not found. Thirdly , your current issue as to why it always show it as a part of fibonacci sequence , put condition k==c instead of k=c.
= is assignment operator which assigns value of c to k. This if will always run.
== checks for equality which is what you wish to do in this code.

Still not working. I made the changes of putting the input of k before the loop starts and the == sign for equality of k and c. Now it says that it is not a part of fibonacci sequence always.

@aryanpandeya
That is because you are not checking k with all values of c anymore , just the last one. Put the check condition in the loop only. Refer to this modified code. I have made some changes and marked them using comments. Let me know if you have any doubts regarding it.
Updated Code - https://ide.codingblocks.com/s/118918

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.