I am trying to get user input for any ten numbers and then to print them in reverse order below is my code it executes and gives me result but I am not able to get user input... please help me..

#include<iostream>

int*ReverseArray(int*orig,unsigned short int b)
{
    unsigned short int a=0;
    int swap;
    for(a;a<--b;a++) 
    {
        swap=orig[a];       
        orig[a]=orig[b];    
        orig[b]=swap;       
        }
        return orig;    
    }
int main()
{
    const unsigned short int SIZE=10;
    int ARRAY[SIZE]={1,2,3,4,5,6,7,8,9,10};
    int*arr=ARRAY;

    for(int i=0;i<SIZE;i++)
    {
        std::cout<<arr[i]<<' ';
    }
    std::cout<<std::endl;
    arr=ReverseArray(arr,SIZE);
    for(int i=0;i<SIZE;i++)
    {
        std::cout<<arr[i]<<' ';
    }
    std::cout<<std::endl;
    std::cin.get();
    return 0;
}

Recommended Answers

All 2 Replies

char ans = '\0';
int i=0;

do{

          cout << "\nEnter a number:  ";
          cin >> arr[i];

          cout << "\nWould ye' like to enter another number?  (Y/N) ";
          cin >> ans;

          i++;

     }while((ans == 'Y' || ans == 'y') && i < SIZE);

can you explain this to me,please..
int*ReverseArray(int*orig,unsigned short int b)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.