Hi, I was trying to understand precedence of pre/post increment/decrement operators. But it seems to be very confusing. According to precedence rule pre increment has higher precedence than addition(+) and lower precedence than post lineament. But when I use any expression like j= i + ++i + i + ++i; according to precedence rule pre icrements will be performed first and then remaining statement. suppose value of i=2, according to precedence rule pre increments will be performed first and then addition. So after two pre increments value of i becomes four and this value should be used in evaluation of complete statement and it should be 16 but it is not. What is correct rule of precedence in this case ?? Similarly in C, generally white spaces does not make any sense but in following case they are they are behaving differently.consider following statements: j = i +++ i; j= i++ + i; j=i + ++i; j=i + + + i; Please let me know, how are white space treated in this case? please follow a consistent rule. Also clarify precedence rule of these operators.
This is not a good place to learn C/C++ really. But anyways the order of evulating of the operands of + is not specified and could happen in either order as there is no sequence point. Read http://c-faq.com/expr/seqpoints.html .
Thanks Andy.