C++ Program to Copy the Contents of One Array Into Another in the Reverse Order Last Updated : 23 Jul, 2025 Suggest changes Share Like Article Like Report Given an array, the task is to copy these array elements into another array in reverse array.Examples: Input: array: 1 2 3 4 5 Output: 5 4 3 2 1 Input: array: 10 20 30 40 50 Output: 50 40 30 20 10 Let len be the length of original array. We copy every element original_arr[i] to copy_arr[n-i-1] to get reverse in copy_arr[]. C++ // C program to copy the contents // of one array into another // in the reverse order #include <stdio.h> // Function to print the array void printArray(int arr[], int len) { int i; for (i = 0; i < len; i++) { printf("%d ", arr[i]); } } // Driver code int main() { int original_arr[] = {1, 2, 3, 4, 5}; int len = sizeof(original_arr)/sizeof(original_arr[0]); int copied_arr[len], i, j; // Copy the elements of the array // in the copied_arr in Reverse Order for (i = 0; i < len; i++) { copied_arr[i] = original_arr[len - i - 1]; } // Print the original_arr printf(" Original array: "); printArray(original_arr, len); // Print the copied array printf(" Resultant array: "); printArray(copied_arr, len); return 0; } Output: Original array: 1 2 3 4 5 Resultant array: 5 4 3 2 1 Time Complexity: O(len) Auxiliary Space: O(len) K kartik Follow 0 Article Tags : C++ Programs C++ C++ Array Programs Explore C++ BasicsIntroduction to C++3 min readData Types in C++6 min readVariables in C++4 min readOperators in C++9 min readBasic Input / Output in C++3 min readControl flow statements in Programming15+ min readLoops in C++7 min readFunctions in C++8 min readArrays in C++8 min readCore ConceptsPointers and References in C++5 min readnew and delete Operators in C++ For Dynamic Memory5 min readTemplates in C++8 min readStructures, Unions and Enumerations in C++3 min readException Handling in C++12 min readFile Handling in C++8 min readMultithreading in C++8 min readNamespace in C++5 min readOOP in C++Object Oriented Programming in C++8 min readInheritance in C++6 min readPolymorphism in C++5 min readEncapsulation in C++3 min readAbstraction in C++4 min readStandard Template Library(STL)Standard Template Library (STL) in C++3 min readContainers in C++ STL2 min readIterators in C++ STL10 min readC++ STL Algorithm Library3 min readPractice & ProblemsC++ Interview Questions and Answers1 min readC++ Programming Examples4 min read My Profile ${profileImgHtml} My Profile Edit Profile My Courses Join Community Transactions Logout Like