Your problem is the if condition in this line:
if( i > j)
swap ( i, j );
After the preprocessor has replaced your define, these lines look like the following:
if( i > j)
temp=a; a=b; b=temp;
What you expect is the following:
if( i > j)
{temp=a; a=b; b=temp;}
which can be achieved by changing your define to
#define swap(a,b) {temp=a; a=b; b=temp;}
EDIT:
As mentioned by others, a more robust solution would be to define the macro as
#define swap(a,b) do{temp=a; a=b; b=temp;}while(1)
This still requires the variable temp
to be declared by hand.
A good example of a type independent swap macro can be found here: https://stackoverflow.com/a/3982430/5237890