Write C++ program to find reverse of an array

Introduction

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;
}

Result

Write C++ program to find reverse of an array
Write C++ program to find reverse of an array

Leave a Comment