0

Fibonot checking doesn't work.Why?

Check the cod.Why doesn't the code give any output? https://code.sololearn.com/cdw079UX5PtS

30th May 2022, 3:23 AM
KAZI FAISAL MAHMUD
KAZI FAISAL MAHMUD - avatar
6 Antworten
+ 1
KAZI FAISAL MAHMUD 1 - you are taking single input but according to example you should take multiple inputs 2 - how this loop will work when n1 = 1 and n2 = 1 for(i = n1 + 1; i < n2; i++) {
30th May 2022, 3:28 AM
A͢J
A͢J - avatar
+ 1
KAZI FAISAL MAHMUD OK. Moving forward! Why will you need to use break in the for loop? You have a known number of iterations.
30th May 2022, 10:52 AM
Emerson Prado
Emerson Prado - avatar
0
A͢J Check now.Is it okay?
30th May 2022, 3:36 AM
KAZI FAISAL MAHMUD
KAZI FAISAL MAHMUD - avatar
0
KAZI FAISAL MAHMUD Before anything else: the Code Playground runner gives errors and warnings. Pls fix them first, then start concerning the calculations. That said: you declare an array, but only ever use its last item. Why not just declare it as a single int? Also, the while loop has two exit points - break and while - which are redundant. Moreover, you know the number of iterations beforehand. How about a simpler for loop? Another hint: practice better code readability. Use consistent indentation and meaningful variable names. This makes it understandable to other people - including who wants to help you.
30th May 2022, 4:03 AM
Emerson Prado
Emerson Prado - avatar
0
Emerson Prado Thank you.I will try to obey your advices further. Anyway, 'Break' is the exit point of forloop. This problem is to find K'th fibonot(Non-fibonacci number).
30th May 2022, 4:12 AM
KAZI FAISAL MAHMUD
KAZI FAISAL MAHMUD - avatar
0
Suppose, K=7.Then FN[K]==K[7]. But my loop condition is made with n2.So there is a. Chance to overflow of this array.
30th May 2022, 11:11 AM
KAZI FAISAL MAHMUD
KAZI FAISAL MAHMUD - avatar