Question: C++: Update the program below by adding the new requirements in this task. Please describe the results and add short comments to explain program. #include
C++: Update the program below by adding the new requirements in this task. Please describe the results and add short comments to explain program.

#include
using namespace std;
class Arr { private: int size; float* value;
public: Arr(){ }
Arr(int size) { this->size = size; value = new float[size]; }
void setSize(int size) { Arr c(size); this->size = size; }
int getSize() { return size; }
void inputValue() { srand(time(NULL)); for (int i = 0; i > value[i];
value[i] = rand() % (100-1) + 1; }
}
float addSum() { float total = 0.0;
for (int i = 0; i
return total; }
float calcAvg() { return addSum() / size; }
void displayValue() { cout
int binarySearch() { int i, j;
for (i = 0; i
for (j = 0; j
if (value[j] > value[j+1]) { int temp = value[j]; value[j] = value[j+1]; value[j+1] = temp; } } } int x, low = 0, high = size-1;
cout
cin >> x;
while (low
int mid = low + (high - low)/2;
if (value[mid] == x) return mid;
if (value[mid]
else high = mid - 1;
}
return -1; }
};
int main() { int size = 1000; int x;
//cout > size;
Arr c(size);
c.inputValue();
c.displayValue();
float sum = c.addSum();
float avg = c.calcAvg();
int index = c.binarySearch();
cout
if(index != -1) cout
return 0;
}
Task 2: Create an array that holds 1000 random integers between 1-1000. Allow the user to enter an integer to search Create and implement a Linear Search Algorithm If the number exists in the array and output the position If the search key does not exist in the Array simple output value not found. Make sure to try and simulate value in the array and the value not appearing in the array. Execute the program 3 times Describe your results Attach Photos of Source Code and Output
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
