Changes

Jump to: navigation, search

Week 2

435 bytes added, 13:10, 19 May 2010
no edit summary
This will print 50, not 60. It replaces SUM with a+b then operator precedence allows it to multiply first before addition.
 
 
<u>Macros</u>
 
''#define SUM(x, y) (x+y)''
 
''printf("%d\n", SUM(i, j)*2);''
 
''printf("%d\n", SUM(a, b)*2);''
 
Those two statements will have ''i+j'' and ''a+b'' instead.
 
Why not replace SUM(a, b) to a+b in the code instead of telling SUM to do it for you before compilation?
 
You might need to change several different things. Could also make it easier to manage code?
 
Another example: ''#define MAX(x, y) ((x)>(y)?(x):(y))''
1
edit

Navigation menu