I am getting infite loop when run this code. And cannot understand why I am getting infinite loop

okay…
i know dev value are between 0 to 3
and i dont want the value of dev is greater than 3
but i don’t understand the reason of infinite loop.