19th Sep 2019, 10:17 AM
Hadjer
Hadjer - avatar
4 Réponses
+ 4
the macro call square(4) will substituted by 4*4 so the expression becomes i = 28/4*4 . Since / and * has equal priority the expression will be evaluated as (28/4)*4 i.e. 7*4 = 28 So output is 28
19th Sep 2019, 10:24 AM
Preity
Preity - avatar
+ 5
If you want to have your intended result, define the macro with parantheses. #define square(x) (x*x) Even better, also put each x in parantheses. This way also input like square(1+3) yields the correct result #define square(x) ((x)*(x)) See this summary for more insight: https://code.sololearn.com/c80ech3GBNvc/?ref=app
19th Sep 2019, 10:50 AM
Matthias
Matthias - avatar
+ 2
Matthias thank you so much ❤
19th Sep 2019, 12:23 PM
Hadjer
Hadjer - avatar
+ 2
Thank you Preity ❤❤
19th Sep 2019, 12:24 PM
Hadjer
Hadjer - avatar