446,389 Members | 1,878 Online
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,389 IT Pros & Developers. It's quick & easy.

# y++

 P: n/a what's the difference between "y++" and "y=y+1"? Mar 16 '07 #1
7 Replies

 P: n/a "ARMAS"

 P: n/a Richard Bos wrote: "ARMAS" what's the difference between "y++" and "y=y+1"? Ignoring stupid homework niggles, nothing whatsoever. Um ... does The value of the expression `y++` is the original value of `y`, while the value of the expression `y=y+1` is the new value of `y`. count as a "stupid homework niggle"? -- Chris "electric hedgehog" Dollin "Go not to the Elves for counsel, for they will answer both no and yes." /The Lord of the Rings/ Mar 16 '07 #3

 P: n/a Chris Dollin

 P: n/a In article <45****************@news.xs4all.nl>, Richard Bos what's the difference between "y++" and "y=y+1"? Ignoring stupid homework niggles, nothing whatsoever. >Um ... does The value of the expression `y++` is the original value of `y`, while the value of the expression `y=y+1` is the new value of `y`.count as a "stupid homework niggle"? >Yes. _As written_, those two do the same thing. _In context_ they mightdo completely different things - you might, for example, also #define ycall_a_complex_function(pointer_to_binary_tree) - but outside ofhomework problems or job applications, I expect such a context to begiven with the problem. _As written_, they do the same thing as foo=76. _In context_ - for example if the variable y is used somewhere else - they may do different things. -- Richard -- "Consideration shall be given to the need for as many as 32 characters in some alphabets" - X3.4, 1963. Mar 16 '07 #5

 P: n/a Richard Bos wrote: Chris Dollin Richard Bos wrote: "ARMAS"

 P: n/a "ARMAS" #include int main() { int init = 0; int y = init; int a = y++; y = init; int b = y = y + 1; printf("%d\n", abs(a - b); return 0; } -Mike Mar 16 '07 #7

 P: n/a Mike Wahler said: printf("%d\n", abs(a - b); return 0; } -Mike Mike - could you use this? ) No charge. -- Richard Heathfield "Usenet is a strange place" - dmr 29/7/1999 http://www.cpax.org.uk email: rjh at the above domain, - www. Mar 16 '07 #8

### This discussion thread is closed

Replies have been disabled for this discussion.