+ 9
Here operation in printf() executed as: prod(x+2,y-1) prod(3+2*4-1) prod(3+8-1) prod(3+7) prod(10) In this way output is 10
7th Jun 2020, 3:52 AM
ツSamarthツ
ツSamarthツ - avatar
+ 2
prod(x + 2, y - 1) = prod(3 + 2, 4 - 1) = 3 + 2*4 - 1 = 3 + 8 - 1 = 10
23rd Feb 2021, 12:36 AM
Diego Pereira
Diego Pereira - avatar
+ 2
Note that the behavior of the prod(i, j) may not be as expected, to fix this, maybe you can state: #define prod(i, j) (i)*(j) This example shows that the define should be used very carefully.
23rd Feb 2021, 12:42 AM
Diego Pereira
Diego Pereira - avatar
+ 1
It happens because multiplication has higher precedence than sum. It is often tricky using preprocessor functions
8th Jun 2020, 9:20 PM
bernborgess
bernborgess - avatar