logo CodeStepByStep logo

swap_all

Language/Type: C arrays
Author: Allison Obourn (on 2020/09/14)

Write a function swap_all that accepts two arrays of integers and a length as parameters and swaps their entire contents.

int a1[3] = {12, 34, 56};
int a2[3] = {20, 50, 80};
swap_all(a1, a2, 3);

After the above code runs the arrays will have the following contents:

a1: {20, 50, 80}
a2: {12, 34, 56}

You may assume that the two arrays are the same length.

Function: Write a C function as described, not a complete program.

You must log in before you can solve this problem.

Log In

Need help?

Stuck on an exercise? Contact your TA or instructor.

If something seems wrong with our site, please

Is there a problem? Contact us.