c - output of a function which has passByName parameter passing paradigm -
this question has answer here:
i've tried figure out output of code .by way ,it not real question, kind of therical question, mean not original c code, kind of pl having c-code syntax , passed name parameter paradigm.
int x=12,y=10; void tswap(int pa, int pb) { int tmp; tmp=pa; pa=pb; pb=tmp; x=x+pa; x=x-pb; y++; printf("%d %d %d %d\n",pa,pb,x,y); } int main() { int a=4; tswap(x,a); printf("%d %d %d\n",x,y,a); tswap(++x,++y); printf("%d %d %d\n",x,y,a); return 0; }
i think output of first part should :
-4 12 -4 11 -4 11 12
but find logical solution part tswap (++x, ++y) there can know how can handle part ?
thanks in advance !
tswap(++x,++y)
is same as:
++x; ++y; tswap(x,y);
making output:
4 12 4 11 4 11 4 12 5 12 13 12 13 4
Comments
Post a Comment