A for
loop consists of 4 parts:
- Initialisation
- Condition
- Body code
- Action
Example:
for (initialisation; condition; action) { Body code }
The execution order is as I enumerated it above.
In your example,
for (int i = 0; i++< 10; a[i-1]){ printf("%i:%i\n");}
- Initialisation -
i = 1
- Condition -
i++< 10;
-->0 < 10 = true
,i = 1
- Body code -
printf
whilei=1
,a[0]
is still uninitialised! - Action -
a[i-1] = i
,a[0] = 1
(only nowa[0]
gets initialised!