0
See the below c program(why the program is ending at 1 and not going upto -infinity?what is the meaning of if(--i)???
#include <stdio.h> int main() { static int i=5; if(--i){ printf("%d\n",i); main(); } } https://code.sololearn.com/cYd6UzlumKli/?ref=app
8 Réponses
0
Hey Vatsav
prefix (--i) decrement 1 from " i " , and any non-zero value is true value for conditional expression , so it print 5,4,3,2,1 and at 0 it becomes false so terminates !
+ 2
If it was i++ or ++i then it can make upto infinity
You can see the above explanation for your understanding.
+ 1
its a prefix expression. examples:
i++
i--
--i
++i
the first couple, increments/decrements the variable after loop completes
the second couple increments/decrements before the variable is read
+ 1
Hey Thirt13n
If should have a condition right? But here there only an decrement function how can we say that condition is true for I>0
+ 1
Why is it not true for zero please explain
0
Hey Vatsav
Any non-zero value is true for conditional expression !
0
Vatsav
Zero(0) mean false !
0
Ok ok got it thanks ☺️☺️☺️