I have used CodeBlocks compiler for debugging purpose. But you can use any C++ programming language compiler as per your availability.
#include <iostream>
#define MAX_SIZE 100 //Maximum size of the array
using namespace std;
int main() {
int array[MAX_SIZE];
int size, i;
// Reading size of array
cout<<"Enter size of the array: ";
cin>>size;
// Reading array elements
cout<<"Enter elements in array: ";
for (i = 0; i < size; i++) {
cin>>array[i];
}
//Print array in reversed order
cout<<"\nArray in reverse order: ";
for (i = size - 1; i >= 0; i--) {
cout<<"\t"<< array[i];
}
return 0;
}
I have used CodeBlocks compiler for debugging purpose. But you can use any C++ programming language compiler as per your availability.
Result:
Enter size of the array: 5
Enter elements in array: 1
2
3
4
5
Array in reverse order: 5 4 3 2 1
need an explanation for this answer? contact us directly to get an explanation for this answer