Find the Output | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
2nd Oct 2019, 5:03 PM
Suresh Rajendiran
3 Answers
+ 3
When using post decrement, On second last iteration, c will have value 1. So after division operation, when it checks the condition while(c--); The condition will evaluate to true (any non zero number is true), after evaluation of condition the value of 'c' will be decremented and it will have 0 now. As the condition was true, so loop body will execute. And any number divided by 0 is infinity. So in case of pre decrement, first c will be equal to 0 and condition will evaluate to false. So it will terminate from the loop.
2nd Oct 2019, 5:59 PM
blACk sh4d0w
blACk sh4d0w - avatar
+ 1
FOLLOW ME Just correct to " --c".
2nd Oct 2019, 5:31 PM
KfirWe
KfirWe - avatar
+ 1
Good.... But put post decrement what will be the Output and why
2nd Oct 2019, 5:36 PM
Suresh Rajendiran