#define( macro) order of execution. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

#define( macro) order of execution.

Could anyone please explain Me. How the code below, executes. Means, what's the order by which each line/statement executes. I thought the output should be : 11 6 11. But it's 12 6 11?... https://code.sololearn.com/cTfE5Mit5Qmk/?ref=app

22nd Mar 2020, 11:07 PM
Syed Waseem
Syed Waseem - avatar
2 Answers
+ 3
Macros work differently from functions. "Macro expansion" is like a dumb copy-paste. After macro expansion, your line 6 becomes: k=((i++)>(j++)) ? (i++):(j++);; Which should explain the strange result. (Also note the extra ";" !) When using macros you always have to be extra careful.
23rd Mar 2020, 1:14 AM
Schindlabua
Schindlabua - avatar
+ 1
Thanks Schindlabua...
23rd Mar 2020, 7:45 AM
Syed Waseem
Syed Waseem - avatar