[Solved] Explain Output in For loop C program [closed]


the condition here is implicit.
C considers as true every integer not null.

the ++i syntax is applied before the condition is evaluated
Therefore the program run as follows:

  • start:
    i=5

  • first loop

condition (++i) => i=6

  • second loop

iteration operation (i-=3) => i=3

condition (++i) => i=4

i is evaluated to true

  • third loop

iteration operation (i-=3) => i=1

condition (++i) => i=2

i is evaluated to true

  • “fourth loop”

iteration operation (i-=3) => i=-1

condition (++i) => i=0

i is evaluated to false

  • end

solved Explain Output in For loop C program [closed]