Hi,
I hope someone can help me understand the result of this program.
Code:
int fun3(int x);
int i = 10, j= -15, b;
main()
{
auto int i = -20;
int y = 7;
y = fun3(i);
getchar();
return 0;
}
int fun3(int a)
{
int b = 1;
++j;
++i;
printf("\n (4)In fun3: Value of a=%d b=%d, i=%d and j=%d", a, b, i, j);
return ++a;
}
It prints out "(4)In fun3: Value of a=-20 b=1, i=11 and j=-14".
I understand that because b was initialized as 1 within the function that it prints as 1 and that i and j are global variables that are incremented within the fuction and therefore have the values 11 and -14 respectively.
On the other hand I can't seem to figure out how a gets the value of -20. Can someone point me in the right direction?