Skip to content

Swap two values

Swap two values

swap receives pointers to two integers and must exchange their values. Through a pointer, *a reads — or writes — the value it points at. Use a temporary variable so you don't lose one value while copying the other.

Log in or create account

IGCSE & A-Level