Question
Write a program swap.c that reads in an array of numbers, and swap the elements in the array such that the first and second elements
Write a program swap.c that reads in an array of numbers, and swap the elements in the array such that the first and second elements are swapped (the first element becomes the second and the second elements becomes the first), the third and fourth elements are swapped, and so on. If the array has an odd number of elements, the last element should remain unchanged. In the main function, ask the user to enter the length of the array, declare the array with the length, and swap the elements and display the array.
Example input/output #1:
Enter the length of the array: 5
Enter the elements of the array: 8 4 1 3 9
Output:
4 8 3 1 9
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started