The output is actually correct for what you are telling it to do. You are
telling to to assing i[j++] to j++. Now, i[j++] is the same as saying
i[0] because j++ only gets incremented after it is used. You probably
want something like i[++j] here. The =j++ does the same thing. So you
are assigning i[0] = 0.
And when you printf the first vaule i[0] is 0 so the output is correcct.
The rest of it is random garbage because it's never been assigned a value.
> Why does this code give the strange output they give?
>
>
> #include<stdio.h>
> main()
> {
> int i[4] ;
> int j = 0;
> i[j++] = j++;
> printf("%d %d %d %d\n",i[0],i[1],i[2],i[3]);
> return 0;
> }
>
>