The swap() Function

Difficulty: ★ ★ ★ ☆

Swapping values is common task in computer programming, often used when sorting. You need the value of variable a in variable b and vice-versa. A number of methods are available for swapping, most of which involve using a temporary variable to hold one of the values during the swap.
Continue reading