C Exercises: Create a new array swapping the first and last elements of a given array of integers and length will be least 1
48. Swap First and Last in Array
Write a C program to create a new array by swapping the first and last elements of a given array of integers whose length is at least 1.
C Code:
Sample Output:
Elements in original array1 are: 1, 5, 7, 9, 11, 13 New array, after swapping first and last elements: 13, 5, 7, 9, 11, 1
Pictorial Presentation:
Flowchart:

For more Practice: Solve these Related Problems:
- Write a C program to swap the second and second-to-last elements of an array.
- Write a C program to reverse the first half of an array while keeping the second half unchanged.
- Write a C program to rotate an array by swapping its extreme elements multiple times.
- Write a C program to swap the first element with every element at an even index.
C Programming Code Editor:
Previous: Write a C program to create a new array from two give array of integers,each length 3.
Next: Write a C program to create a new array of length 3 from a given array (length atleast 3) containing the elements from the middle of the array.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.