Question : void main() { int i=20;j=35,x,y; x= y++ + x++; y= ++y + ++x; printf("
%d %d" , x,y); } /* please tell me the value of x and y at each and every moment. i dont need the answer but the explanation of the anamolus behavior of increment expression.*/
First i explain how the incremental operator works Y++ means increase the value of y by one. the value of y is incremented by one after the first iteration.
++Y means the value of y is first incremented before iteration and value of y is incremented and then the expression evaluates.
In the above expression the result is :
No value is assigned for x & y so when we declare the variables without assigning the values default values may be present so based on that default values the incremental operator works.
suppose the default values of x & y are 10 & 20 then the expression