Wednesday, 4 July 2012

program that reverse an array of n number in c++.

#include<iostream>
using namespace std;

int main()
{
int n,j,temp;

    cout<<"Enter your total number here";
    cin>>n;
    int a[n];
//input from user
        for(j=0;j<=n;j++)
        {
        cout<<"Enter  element at position  " <<j+1<<"  :"
        cin>>a[j];
        cout<<endl;
        }
//reverse array element
       
        for(j=n;j>0;j--)
        {
        cout<<"Enter  element at position  " <<j+1<<"  :"
        cout<<a[j];
        cout<<endl;
        }
        return 0;
}