//C++ code
// this code in c++
#include<iostream>
using namespace std;
void calculate(int* arr,int s, int &min, int &max, double
&avg);
int search(int* arr,int s, int num);
//Function prototype
int main()
{
cout << "Enter the size of array: ";
int size;
cin >> size;
int* a = new int[size];
for (int i = 0; i < size; i++)
{
cout << "Enter number "
<< (i + 1) << ": ";
cin >> a[i];
}
int min=0, max=0;
double avg=0;
calculate(a, size, min, max, avg);
cout << "Max = " << max<<endl;
cout << "Min = " << min <<
endl;
cout << "Avg = " << avg <<
endl;
cout << "Number to be searched: ";
int num;
cin >> num;
int index = search(a, size, num);
if (index < 0)
cout << num << " not
found..." << endl;
else
cout << num << " is
found at " << index << endl;
//pause
system("pause");
}
void calculate(int* arr,int s, int &min, int &max, double
&avg)
{
max = *arr;
min = *arr;
int sum = 0;
for (int i = 0; i < s; i++)
{
if (min > arr[i])
min =
arr[i];
if (max < arr[i])
max =
arr[i];
sum += arr[i];
}
avg = (double)sum / s;
}
int search(int* arr,int s, int num)
{
for (int i = 0; i < s; i++)
{
if (arr[i] == num)
return i;
}
return -1;
}
//Output

//If you need any help regarding this solution..... please leave a comment.......... thanks
Write a program that dynamically allocates an integer array of size of 20 to hold a...
Write a program that dynamically allocates an array in the freestore large enough to hold a user defined number of test scores as doubles. Once all the scores are entered, the array should be passed to a function that finds the highest score. Another function the array should be passed to a function that finds the lowest score. Another function should be called that calculates the average score. The program should show the highest, lowest and average scores. Must use...
Write a program that dynamically allocates an array in the freestore large enough to hold a user defined number of test scores as doubles. Once all the scores are entered, the array should be passed to a function that finds the highest score. Another function the array should be passed to a function that finds the lowest score. Another function should be called that calculates the average score. The program should show the highest, lowest and average scores. Must use...
Write a C++ program that dynamically allocates an array large enough to hold a user-defined number of test scores. Once all the scores are entered, the array should be passed to a function that sorts them in ascending order. Another function should be called that calculates the average score. The program should display the sorted list of scores and averages with appropriate headings. Use pointer notation rather than array notation whenever possible. Input Validation: Do not accept negative numbers for...
read it carefully C++
Question: Write a program that dynamically allocates an array large enough to hold a user-defined number of test scores. Once all the scores are entered, the array should be passed to a function that sorts them in ascending order. Another function should be called that calculates the average score. The program should display the sorted list of scores and averages with appropriate headings. Use pointer notation rather than array notation whenever possible. Input Validation: Do not...
Write a program that uses pointer notation to dynamically allocate parallel array(s) large enough to hold a user-defined number of test scores and student names, using parallel arrays. After student names and corresponding scores are entered, the array(s) should be passed to a function that sorts them in ascending order. Another function should be called that calculates the average score for the group (do not include the lowest score in the calculation of average grade). The program should display the...
Class Average Create a program that dynamically creates an array whose size depends on the user's preference. Pass the array to a calculate_avg function that is responsible for computing the average GPA of the given array. Use pointer arithmetic throughout your program. calculate_avg Create a function called calculate_avg that calculates the average of a double array and returns that average. calculate_avg() will have two parameters: a double* referring to the array an int that contains the size of the given...
C++ programming language POINTERS Write a program that dynamically allocates an array, on the Heap, large enough to hold 200 test scores between 55 and 99 -- using a Random Number generator to populate the array. Then do the following: 1) Sort scores in ascending order. 2) List your scores in rows of ten(10) values. 3) Calculate the Mean for the distribution. 4) Calculate the Variance for the distribution. 5) Calculate the Median for the distribution. 6) Calculate the Mode...
Write the code to dynamically allocate ONE integer variable using calloc (contiguous allocation) or malloc (memory allocation) and have it pointed to by a pointer (of type int * ) named ptr_1. Use ptr_1 to assign the number 7 to that dynamically allocated integer, and in another line use printf to output the contents of that dynamically allocated integer variable. Write the code to dynamically allocate an integer array of length 5 using calloc or malloc and have it pointed...
Create a function that takes in an integer array called “input” and size. The function should return a pointer to a dynamically created array the has two locations. The first is the minimum number in the input array and the second is the maximum number in input. Demonstrate your work by calling this function in main. The program should be c++
IN C++ ADD COMMENTS AS MUCH AS POSSIBLE Exercise 1: Duplicate the Arrays Suppose you are developing a program that works with arrays of integers, and you find that you frequently need to duplicate the arrays. Rather than rewriting the array-duplicating code each time you need it, you decide to write a function that accepts an array and its size as arguments. Creates a new array that is a copy of the argument array, and returns a pointer to the...