+ 2
C++ for loop in my code not working
Sorry my for loop not working (line 46), can anyone enlighten me? https://code.sololearn.com/cyoZC0Oo06Nu/?ref=app
5 Respostas
+ 5
The mistake is indeed hard to spot. I handtraced it to line 24 though.
Go through your function with 100 as the argument. You'll notice that in line 24, you indirectly divide by 0 - remainder needs division - and thus the program stops working.
You should make an extra else-if case that covers 0.
+ 3
Interesting
I'm trying for a while
I found out something
it's if who is disturbing and if covers function
+ 2
line 49 is added to check whether the problem is with for loop or with the function isGapful, thus the output looks weird.
+ 1
Yep if we start from 101 it works weirdly but works
edit: because of other cout i
+ 1
Thanks for finding out that the problem occur at line 24.
I should use n2=n2/10 at line 11.