--- In [email protected], piyush dixit <piyush_4love_4e...@...> wrote:
>
> i m not asking for right code.
If you just want to write bad code, stop wasting our time!
> i want to know why the result is 10 0 0.
You've already been given enough clues. John kindly expanded
the macro for you [albeit missing an extra semi-colon.] I've
pointed you the C FAQ covering the issue. Please read the
entire FAQ, not just the sections I posted.
And next time, please show us your attempt to trace through
the code, rather than simply repeating the question.
It seems your issue is that you don't understand preprocessing
as pure text substitution. It occurs _prior_ to the code being
semantically analysed.
The code...
if(i>j) swap(i,j);
...expands to...
if(i>j) temp=i;i=j;j=temp;;
...which, after adding some whitespace, is just...
if (i > j)
temp=i;
i=j;
j=temp;
;
Which executes as...
/* i = 5, j = 10; temp = 0 */
if (i > j) /* 5>10 is false */
temp=i; /* skipped */
i=j; /* i = 10, j = 10; temp = 0 */
j=temp; /* i = 10, j = 0; temp = 0 */
; /* i = 10, j = 0; temp = 0 */
--
Peter