eval order

void show(itn x, int y,int z)
{
printf("%d %d %d",x,y,z);
}
int main()
{
int a=10;
show(a,a++,++a);
return 0;
}

what can be the o/p of this program on different compilers.Will it be predictable?

Comments

  1. C Standard says between two sequence points an object's stored value can be modified once.A sequence point occurs in the following conditions:

    1> At the end of full expression.
    2> At the end of &&,||,?: operator.
    3> At a function call(after the evaluation of all arguments i.e. just before the actual call)

    So,according to the last condition the answer will be that the output of the programme will be compiler dependent.

    ReplyDelete

Post a Comment

Popular posts from this blog