Increment Operators vs. Precedence

Don Thomson thomson at zazen.macc.wisc.edu
Wed Mar 6 09:34:21 AEST 1991


So here I am teaching an introductory C class and have just finished
precedence and associativity and moved on to prefix and postfix increment
operators.  The example on the board is y = x++, and I explain that x gets
assigned to y before x is incremented.  An astute individual in the back of
the room raises his hand and points out that according to what I just taught
them, the precedence is wrong, that in fact the assignment operator has a
significantly lower precedence than ++.  So the dilemma is how to explain that
precedence is not the issue here, that the order of operations is tied to the
definition of prefix versus postfix increment operators.  Any ideas on how to
word the explanation in such a way that I don't leave them forever suspicious
about what does and what does not have to obey precedence rules?
--
 
----- Don Thomson ----- MACC, 1210 W. Dayton, Madison, WI  53706 -------------
    (608) 262-0138      thomson at macc.wisc.edu / thomson at wiscmacc.bitnet



More information about the Comp.lang.c mailing list