+ 1

What is the problem with this code??

It's counting infinitely it is just not working as intended. https://code.sololearn.com/c9hd1E2hBCH2/?ref=app

8th Aug 2019, 5:05 AM
ĐɆⱤɆJɆ the₲reat
ĐɆⱤɆJɆ the₲reat - avatar
4 Réponses
+ 4
unsigned int i, it means that the variable i will always be >= 0 (greater or equal). but let's understand this better: it means that i will never be a negative number because it doesn't have a sign. you can put as condition: while ( i != 0) to exit the loop
8th Aug 2019, 11:53 AM
notqueued
notqueued - avatar
+ 3
unsigned i = 0; while (i >= 0) i++; this means that i will always be greater or equal to 0 and the loop will never end
8th Aug 2019, 5:15 AM
notqueued
notqueued - avatar
8th Aug 2019, 8:03 AM
ĐɆⱤɆJɆ the₲reat
ĐɆⱤɆJɆ the₲reat - avatar
+ 2
Oh i see ! Thanks a lot :)
9th Aug 2019, 9:25 AM
ĐɆⱤɆJɆ the₲reat
ĐɆⱤɆJɆ the₲reat - avatar