1#include <iostream>
2
3// Print contents of an array in reverse order in C++
4// using array indices
5int main()
6{
7 int arr[] = { 10, 20, 30, 40 };
8 size_t n = sizeof(arr)/sizeof(arr[0]);
9
10 // iterate backwards over the elements of an array
11 for (int i = n - 1; i >= 0; i--) {
12 std::cout << arr[i] << ' ';
13 }
14
15 return 0;
16}
17