basics · beginner · ~15 min

Swap two integers

Mutate caller variables via pointers.

Challenge

Implement void swap_int(int *a, int *b) swapping the two values through their pointers.

Starter code

void swap_int(int *a, int *b) {
    /* TODO */
}

Solve this exercise in the browser editor — compile and run against the test harness, no setup required.