Reverse the Second Half of Array Elements
For Complete YouTube Video: Click Here
In this class, we will understand Reverse the Second Half of Array Elements.
The entire course of C Programming with more than 110+ videos of content or playlist has already been published.
We have covered all the concepts of C Programming in a very detailed way.
C Programming Complete Playlist on YouTube: Click Here
All the concepts discussed in this course are the models frequently asked in Campus Placements Questions, either in multiple-choice questions or as programming questions.
This entire course will help a Computer Science Engineering Student or a student in any other stream crack the campus placements drives held by Service-based Software or IT companies like TCS, Infosys, CTS, Wipro, Accenture, etc.
Table of Contents
Reverse the Second Half of Array Elements
Question
In this program, we have to reverse the second half of the array elements.
The test cases and the given program are as shown below.
Example1:
Input: 7, [1, 2, 3, 4, 5, 6, 7]
Output: 1, 2, 3, 7, 6, 5, 4
Example2:
Input: 4, [1, 2, 3, 4]
Output: 1, 2, 4, 3
void reverseHalfArray(int size, int *inputList) { int i, temp; for(i=0;i<size/2;i++) { temp = inputList[size-1]; inputList[size-1] = inputList[i]; inputList[i] = temp; size -= 1; } }
In the above code, there are some mistakes in the problem.
The explanation of the question is provided in the above YouTube link.