Lets see what happen with ur code...

original
# define swap(a,b) temp=a; a=b; b=temp;
main( )
{
int i, j, temp;
i=5;
j=10;
temp=0;
if( i > j)
swap( i, j );
printf( “%d %d %d”, i, j, temp);
}


after expansion of macro

# define swap(a,b) temp=a; a=b; b=temp;
main( )
{
int i, j, temp;
i=5;
j=10;
temp=0;
if( i > j)
*temp=a;  //only this line comes under if condition*
a=b;
 b=temp;
printf( “%d %d %d”, i, j, temp);
}

On Sat, Aug 6, 2011 at 10:26 AM, saurabh singh <[email protected]> wrote:

> Try compiling with gcc -E <filename.c>.That will clear everything....
>
>
> On Sat, Aug 6, 2011 at 10:25 AM, saurabh singh <[email protected]>wrote:
>
>> hint:MACRo is just substituted as it is....
>>
>>
>> On Sat, Aug 6, 2011 at 10:23 AM, ranjane <[email protected]> wrote:
>>
>>> # define swap(a,b) temp=a; a=b; b=temp;
>>> main( )
>>> {
>>> int i, j, temp;
>>> i=5;
>>> j=10;
>>> temp=0;
>>> if( i > j)
>>> swap( i, j );
>>> printf( “%d %d %d”, i, j, temp);
>>> }
>>>
>>>
>>> On compiling i got ans 10, 0, 0.explain..
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "Algorithm Geeks" group.
>>> To post to this group, send email to [email protected].
>>> To unsubscribe from this group, send email to
>>> [email protected].
>>> For more options, visit this group at
>>> http://groups.google.com/group/algogeeks?hl=en.
>>>
>>>
>>
>>
>> --
>> Saurabh Singh
>> B.Tech (Computer Science)
>> MNNIT ALLAHABAD
>>
>>
>>
>
>
> --
> Saurabh Singh
> B.Tech (Computer Science)
> MNNIT ALLAHABAD
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>



-- 
**Regards
SAGAR PAREEK
COMPUTER SCIENCE AND ENGINEERING
NIT ALLAHABAD

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to