I'm trying to write a lab for my c++ class and a can't seem to get my pointer "ptrarray" to increment by a number set by the user based on the initial number of the array also set by the user. I have tried multiple attempts, but I can only get the first number to increment and then the rest are useless groups of numbers. Any help would be appreciated.
int main()
{
int choice;
cout << "3 Demos will be presented to you. \n";
cout << "The first will allow you to select the \n";
cout << "size of an array, its starting value, \n";
cout << "and the number in which it is incremented by." << endl;
cout << "The second will create a 9x9 array of \n";
cout << "random numbers. The final uses a pointer \n";
cout << "as an argument of a function.\n" << endl;
cout << "Choose what demo you would like to run. \n\nEnter '1' for demo 1\n\nEnter '2' for demo 2";
cout << "\n\nEnter '3' for demo 3\n" << endl;
cin >> choice;
if(choice == 1)
{
int size, i, inc;
cout << "Enter the size of the desired array: ";
cin >> size;
int *ptrarray = new int[size];
cout << "Enter the first number of the array: ";
cin >> ptrarray[0];
cout << "\n\nEnter an integer to increment the array by: ";
cin >> inc;
for (i = 0; i < size; i++)
{
*(ptrarray+i) = *(ptrarray+i)+inc;
}
cout << "\nThe array created is: " << endl << endl;
for (i = 0; i < size; i++)
{
cout << setw(5) << ptrarray[i];
}
cout << "\n\n\nNow the memory will be set free." << endl;