reversing array in c++ code example
Example 1: reverse an array in cpp
#include<iostream>
using namespace std;
int main()
{
int n=3;
int arr[]={1,2,3,4};
while (n>=0)
{
cout<<arr[n];
n--;
}
return 0;
}
Example 2: c++ program to reverse an array
#include<iostream>
using namespace std;
int main()
{
int a[]={1,2,3,4,5}; // Using Pointer and Array Relationship
for (int i = 4; i>=0; i--)
cout<<*(a+i);
return 0;
}