C is pass-by-value, so the swap
function receives copies of the values, and cannot affect the variables in the caller.
To affect the variables in the caller, you need to pass pointers to them.
void swap(int *a, int *b) {
int temp = *a;
*a = *b;
*b = temp;
}
and call it
swap(&x, &y);
in main
.