i am using following code in selection sort program for swap the value.When i pass arguments like swap(a[min],a[j]) It swaps the values but doesn't increment the "swaps" variable.
But when i pass arguments like swap(&a[min],&a[j]) It swaps the value as well as increment the "swaps" variable. I didn't get what is happening under the hood.
I am using minGW compiler.
void swap(int *x,int *y)
{
swaps++;
int temp;
temp=*x;
*x=*y;
*y=temp;
}