C
tmp = x;
x = y;
y = tmp;
void swap(int *a, int *b) {
int tmp;
tmp = *b;
*b = *a;
*a = tmp;
}
swap(&x, &y);
x = x + y;
y = x - y;
x = x - y;
x = x ^ y;
y = x ^ y;
x = x ^ y;
CoffeeScript
[x, y] = [y, x]
Java
tmp = x;
x = y;
y = tmp;
JavaScript
tmp = x;
x = y;
y = tmp;
x = [y, y = x][0];
[x, y] = [y, x]
Kotlin
tmp = x
x = y
y = tmp
Objective-C
tmp = x;
x = y;
y = tmp;
Perl
($x, $y) = ($y, $x);
PHP
list($x, $y) = array($y, $x);
function swap(&$x, &$y) {
$tmp = $x;
$x = $y;
$y = $tmp;
}