C++ Program to Reverse All the Strings Stored in an Array: You will get C++ program to reverse all the strings stored in an array.
C++ Program to Reverse All the Strings Stored in an Array
#include <iostream>
#include <algorithm>
using namespace std;
void print(int arr[], int n)
{
for (int i = 0; i < n; i++) {
cout << arr[i] << " ";
}
}
void reverse(int arr[], int n)
{
reverse(arr, arr + n);
}
int main()
{
int arr[] = { 1, 2, 3, 4, 5 };
int n = sizeof(arr)/sizeof(arr[0]);
reverse(arr, n);
print(arr, n);
return 0;
}
Output of Program
5 4 3 2 1