how could i display the reverse the values of the array that are random numbers using pointers.
So far this is what I have. it displays the array but it does not display the reverse.

#include "stdafx.h"
#include <iostream> 
#include <ctime> 
#include <cstdlib> 
const size = 10;
typedef int* IntPtr;

void input_array(int a[], int size);

void reverse(int a[], int size);

int index;

using namespace std; 

int main() 
{ int a[size];

input_array(a, size);

cout << endl;

reverse (a, size);


return 0;

void input_array(int a[], int size)

int random_integer; 
int lowest, highest; 

cout << "enter the range of the values lowest first then the highest\n";
cin >> lowest >> highest;

cout << "The random array with a size " << size << endl;
cout << endl;

int range=(highest-lowest)+1;

for( index=0; index < size; index++)
random_integer = lowest+int(range*rand()/(RAND_MAX + 1.0)); 
 a[index] = random_integer;

cout << a[index] << " ";


void reverse(int a[], int size)
IntPtr p1;

p1 = a;

cout << "The reverse of the array is\n";
cout << endl; 

for (index = 9; index<0; index--)
	cout << p1[index] << endl;


for (index = 9; index<0; index--)


for (index = 9; index>=0; index--)

. And since you are passing the size of the array use that instead of the hard coding 9. Like this

for (index = size; index>=0; index--)
This article has been dead for over six months. Start a new discussion instead.