- 1

Why is output -2?

signed int i=10; while(i>0) i=i-4; printf("%d",i);

9th May 2020, 2:20 PM
Karan Dewangan
Karan Dewangan - avatar
3 Answers
+ 2
Also a loop without parentheses runs the only first statement ,
9th May 2020, 2:30 PM
Abhay
Abhay - avatar
+ 1
It is easy pissy The while condition will false when the i is less than 0 so in 3rd iteration (repeatation) i become -2 a while loop end And prints -2
9th May 2020, 2:24 PM
Abhay
Abhay - avatar