Reverse an array in C with a swap function.
Budget: £10 – £20 GBP
I am teaching myself C online and am trying to complete a question to reverse an array using a specific swap function.
Can someone show me how to do this as I am not able to achieve the outcome I need using a swap function.
Question:
(a). Ask the user to enter 5 integers and store them in an array.
(b). Print the elements stored in the array.
(c). Pass the array and the array size to the swap function which will swap the values in the opposite order.
(d). Print the swapped array in the main function.
I have to use the function prototype below for the swap function, and this is what I am finding difficult.
Function prototype: void swap(int[], int);
An example of the completed output would be the following:
Input 5 numbers:
1
22
3
55
6
Numbers are: 1, 22, 3, 55, 6
After Swapping: 6, 55, 3, 22, 1
Can someone please show how i would solve using the "void swap(int[], int)" function.
Can someone show me how to do this as I am not able to achieve the outcome I need using a swap function.
Question:
(a). Ask the user to enter 5 integers and store them in an array.
(b). Print the elements stored in the array.
(c). Pass the array and the array size to the swap function which will swap the values in the opposite order.
(d). Print the swapped array in the main function.
I have to use the function prototype below for the swap function, and this is what I am finding difficult.
Function prototype: void swap(int[], int);
An example of the completed output would be the following:
Input 5 numbers:
1
22
3
55
6
Numbers are: 1, 22, 3, 55, 6
After Swapping: 6, 55, 3, 22, 1
Can someone please show how i would solve using the "void swap(int[], int)" function.