0

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

Edited by Nick Evan: Fixed formatting

3
Contributors
2
Replies
3
Views
8 Years
Discussion Span
Last Post by tkud
0
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);

Edited by Clinton Portis: n/a

0

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

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.