



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




(see end of document for original question)
#include
void main() { int size, i; cout << "Enter the size of the array: " << endl; // asks user for size cin >> size; double * arr; arr = new double[size]; double newValue; double deleteValue;
cout << "Enter the values you want: " << endl; for (i = 0; i < size; i++) cin >> arr[i];^ //filling array
cout << "The array you entered is: " << endl; printArr(arr, size); //calling function of print
cout << "Enter the new value that you want to add: " << endl; cin >> newValue;
cout << "The added array is: " << endl; arr = addValue(arr, size, newValue); //calling function of addvalue and assigning it to arr printArr(arr, size); cout << endl; cout << "Enter the new value that you want to add: " << endl; cin >> newValue;
cout << "The added array is: " << endl; arr = addValue(arr, size, newValue); //the last arr has the new &size and so on printArr(arr, size);
cout << endl;
cout << "Enter the value that you want to delete: " << endl; cin >> deleteValue; cout << "The deleted array is: " << endl; arr = del(arr, size, deleteValue); //calling delete and assigning arr = arr3 from that function printArr(arr, size);
cout << endl;
if (arr[i] != deleteValue) //copies all numbers except for the deletevalue { arr3[j] = arr[i]; j++; } }
delete[] arr; //delete arr so that we can assign it to arr
return arr3;
void printArr(double* arr, int size) { for (int x = 0; x < size; x++) { cout << arr[x] << "^ "; }
cout << endl;