logo CodeStepByStep logo

swap

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

Write a function called swap that accepts an array of integers and two indexes as parameters and swaps the elements at those indexes.

int a1[3] = {12, 34, 56};
swap(a1, 1, 2);

The above code should change the array to store {12, 56, 34}. You may assume that the two indexes lie within the bounds of the array.

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.