so I needing some help with creating a program for my class. The lab requires us to use pointers. This is the description of what we have to do...
-Write a function that accepts an int array and the array's size as arguments. -The program should ask the size of the array and lets the users enter some integer values. -The function should create a new array that is one element larger than the argument array. -The first element of the array should be set to 0. -Element 0 of the argument array should be copied to element 1 of the new array. -Element 1 of the argument array should be copied to element 2 of the new array, etc. -The function should return a pointer to the new array. -There should be three other functions: getMode, getMedian and getAverage. -These functions should get Mode, Median and Average of the values within an array. -You should display the argument array and the new array as well as the mode, median and the average.
This is what I have so far I'm not sure if its right. Any help is greatly appreciated. UPDATE: I run the program and it asks the user for the size of the array and the values for it...
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <string>
int* addToSize (int*, int);
using namespace std;
int main()
{   
    int userSize=0; //Holds user size
    int userInts; //Holds uaer values
    int *memory; //dynamically allocate an array
    //int  *intptr;
    //int *arrayNew;
    //int newA;
    //Gets array size
    cout << "Please enter the array size!" << endl;
    cin >> userSize; 
    //Memory array 
    memory = new int [userSize];
    //Grab values for the amount of user size 
    for (int count = 0; count < userSize; count ++)
    {
        cout << "Please enter the value for " << count+1 << endl;
        cin >> userInts;
    }
    for (int index = 0; index < userSize; index ++)
    {
        cin >> memory[index];
    }
    //Sets addToSize function to memory array
    memory = addToSize(memory, userSize);
   //Shows memory array
    for(int index=0;index< (userSize + 1);index++)
        cout<<memory[index]<<endl;
    delete[] memory;    //Used to delete memory array
    memory = 0; //sets memory array to 0
    return 0;
}
    int* addToSize(int* arrayNew, int newSize) 
{
    int* expandSize= new int [newSize +1];
    for (int index = 0; index < newSize; index++)
    {
        expandSize[index]= arrayNew[index];
    }
    for (int index = newSize; index < (newSize+1); index ++) 
    {
        expandSize[index]=0;
    }   
    return expandSize;
}
 
    