C++ Program to Copy the Contents of One Array Into Another in the Reverse Order Last Updated : 23 Jul, 2025 Comments Improve Suggest changes 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) Comment More infoAdvertise with us K kartik Follow Improve Article Tags : C++ Programs C++ C++ Array Programs Explore Introduction to C++Introduction to C++ Programming Language2 min readHeader Files in C++5 min readSetting up C++ Development Environment8 min readDifference between C and C++3 min readBasicsC++ Data Types7 min readC++ Variables4 min readOperators in C++9 min readBasic Input / Output in C++5 min readControl flow statements in Programming15+ min readC++ Loops7 min readFunctions in C++8 min readC++ Arrays8 min readStrings in C++5 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++11 min readFile Handling through C++ Classes8 min readMultithreading in C++8 min readNamespace in C++5 min readC++ OOPInheritance in C++10 min readC++ Polymorphism5 min readEncapsulation in C++4 min readAbstraction in C++4 min readStandard Template Library(STL)Containers in C++ STL3 min readIterators in C++ STL10 min readC++ STL Algorithm Library2 min readPractice C++C++ Interview Questions and Answers1 min readTop C++ DSA Related ProblemsC++ Programming Examples7 min read Like