How to Reverse an Array using STL in C++? Last Updated : 11 Jul, 2025 Summarize Comments Improve Suggest changes Share Like Article Like Report Try it on GfG Practice Reversing an array means rearranging its elements so that the first element becomes the last, the second element becomes the second last, and so on. In this article, we will learn how to reverse an array using STL in C++.The most efficient way to reverse an array using STL is by using reverse() function. Let’s take a look at a simple example: C++ #include <bits/stdc++.h> using namespace std; int main() { int arr[] = {1, 3, 4, 7}; int n = sizeof(arr) / sizeof(arr[0]); // Reverse the array arr reverse(arr, arr + n); for (auto i : arr) cout << i << " "; return 0; } Output7 4 3 1 This method reverses the array in-place i.e. it modifies the original array and rearranges it in reverse order.Apart from the reverse() function, STL also provides some other methods to reverse an array. Some of them are as follows:Table of ContentUsing reverse_copy()Using copy() (C++ 11 Onwards)Using reverse_copy()The reverse_copy() function can also be used to reverse an array. It is similar to the reverse() function but it does not modify the original array, instead it stores the reversed version in a separate array. C++ #include <bits/stdc++.h> using namespace std; int main() { int arr[] = {1, 3, 4, 7}; int n = sizeof(arr) / sizeof(arr[0]); int rev[n]; // Reverse the array arr reverse_copy(arr, arr + n, rev); for (auto i : rev) cout << i << " "; return 0; } Output7 4 3 1 Using Reverse IteratorsThough array doesn't have inbuilt reverse iterators, they can be created using rbegin() and rend() function. Then copy() function can be used to copy the elements in the reverse order in some separate array. C++ #include <bits/stdc++.h> using namespace std; int main() { int arr[] = {1, 3, 4, 7}; int n = sizeof(arr) / sizeof(arr[0]); int rev[n]; // Copy all elements into another array // in reversed order copy(rbegin(arr), rend(arr), rev); for (auto i : rev) cout << i << " "; return 0; } Output7 4 3 1 Comment More infoAdvertise with us Next Article How to Reverse a Vector using STL in C++? C code_r Follow Improve Article Tags : Misc C++ Programs C++ STL cpp-array cpp-algorithm-library CPP Examples +3 More Practice Tags : CPPMiscSTL Similar Reads How to Reverse a Vector using STL in C++? Reversing the vector means the swapping last element and first element, second last element and second element, and so on. In this article, we will learn how to reverse a vector using STL in C++.The most efficient method to reverse the vector is by using reverse() function. Letâs take a look at a si 3 min read How to Reverse a Vector Using a Stack in C++? In C++, the stack container follows the LIFO (Last In First Out) order of operation. It means that the element first inserted will come out at last while the element that was last inserted will come out first. In this article, we will learn how we can use stack to reverse a vector in C++ Example Inp 2 min read How to Reverse a Word Using Stack in C++? In C++, we have a stack data structure that follows the Last In First Out (LIFO) principle. In this article, we will learn how to reverse a word using a stack in C++. Example: Input:word = "GeeksforGeeks"Output:Reversed Word: skeeGrofskeeGReverse a String Using Stack in C++To reverse a word using a 2 min read How to Reverse a List in C++ STL? In C++, std::list is a sequence container that allows non-contiguous memory allocation. As such, it is a doubly linked list that can be traversed in both directions. In this article, we will learn how to reverse a list in C++. Example: Input: myList = {10, 20, 30, 40, 50}; Output: Reversed List: 50 2 min read How to Reverse a Stack in C++? In C++, stacks are containers that store the elements in the last in-first out order(LIFO). In, this article, we will learn how we can reverse a stack in C++. Example Input: stack<int> S ={5,4,3,2,1} store Output: // Reversed Stack stack<int> S ={1,2,3,4,5}Reverse a Stack in C++We can re 2 min read All reverse permutations of an array using STL in C++ Given an array, the task is to print or display all the reverse permutations of this array using STL in C++. Reverse permutation means, for an array {1, 2, 3}: forward permutations: 1 2 3 1 3 2 2 1 3 2 3 1 3 1 2 3 2 1 reverse permutations: 3 2 1 3 1 2 2 3 1 2 1 3 1 3 2 1 2 3 Examples: Input: a[] = { 3 min read Like