Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

can someone fill in my code? #include using namespace std; // Prototype for printArray function //-->void printArray(int [], int ); // Prototypes for min and

can someone fill in my code?

#include using namespace std; // Prototype for printArray function //-->void printArray(int [], int ); // Prototypes for min and max functions //-->int min(int [], int ); //-->int max(int [], int ); // Prototype for sum function //-->int sum(int [], int ); // Prototype for average function //-->double average(int [], int); // Prototype for search function //-->int search(int [], int, int); int main() { //Create a constant integer called MAX_SIZE with value 10 //Create an array of integers called 'ar' with size MAX_SIZE. const int MAX_SIZE = 10; int ar[MAX_SIZE]; //Declare an integer called arraySize and initialize it to 0. This will hold the number of //integers the user enters. //--> //Declare a boolean called quit and set it to false. //--> //Ask the user to fill the array in a loop. //It should start from the beginning of the array and keep filling the array //till the user enters 0 or the array gets filled. //continue to loop while the index is still valid AND quit is still false for(int i=0; i //--> //If the current element of array  is not zero then the size of the array is increased by one (increase  by one) //Otherwise, if the number is zero and the user wants to quit (set the  to true) //-->if (???) //--> arraySize++; //-->else //--> quit = true; } //Print out the array using the method printArray(int[], int). cout<<" The array is: "; //--> /************ 1. Calculating the minimum number in the array *************/ //--> cout<<"The smallest number in the array is:\t\t " << ??? <<" "; /************ 2. Calculating the maximum number in the array *************/ //Complete the cout by calling the max method (refer to how min is done above) //--> cout<<"The largest number in the array is:\t\t " << ??? <<" "; /************** 3. Calculating the average of numbers in an array ***********/ //Similarly print the average //-->cout<<"The average of the numbers in the array is:\t " <> num; // Call search function and pass required inputs //--> //If the number is not found print out ' does not occur in the array' where  is the number searched for. //Otherwise print out ' occurs in the array for the first time at position ' //--> } //This method takes an array of integers and the size of the array as parameters //and prints the elements of the array separated by commas inside brackets. /* ??? printArray(???, ??) { cout<<"["; // Use a for loop and iterate from 0 till the size of the array and inside the loop print each element of input array  //--> cout<<"] "; } */ //This method takes an array of integers and the size of the array as parameters // and returns the minimum element in the array /* ??? min(???, ???) { int min; if (size > 0) min = a[0]; else min = 0; // Loop through the array  from 1 till the size of the array //--> { // if the current element in the array  is less than  then assign current element in  to  //--> } return min; }*/ //This method takes an array of integers and the size of the array as parameters // and returns the maximum element in the array /* ??? max(???, ???) { int max; if (size > 0) max = a[0]; else max = 0; // Loop through the array  from 1 till the size of the array //--> { // if the current element in the array  is greater than  then assign current element in  to  //--> } return max; } */ //This method takes an array of integers and the size of the array as parameters // and returns the sum of the elements in the array /* int sum(???, ???) { int sum=0; // Loop through the array  and keep adding each element to the variable  return sum; } */ //This method takes an array of integers and the size of the array as parameters // and returns the average of elements in the array /* double average(int a[], int size) { //If the size is zero return zero //Otherwise return the sum (call the sum method above) divided by the number //of elements in the array (it's size). //Remember to cast one of the terms of the division as a double. //--> } */ //WRITE THE FOLLOWING METHOD int search(int[], int, int) //This method takes an array of integers, an integer to search for in the array // and the size of the array as parameters // and returns the first index of the array the number is found at // or -1 if the number is not found in the array. //Hint: Loop over the elements in the array and if any of the elements // is equal to the number you are searching for return that index (Note index and not element) // If the loop exits return -1. /* ??? search(???, ???, ???) { // Loop through the array  using a loop variable  //--> { // if the current element in  is  return the loop varaible  //--> } return -1; }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Students also viewed these Databases questions

Question

b. Does senior management trust the team?

Answered: 1 week ago

Question

c. How is trust demonstrated?

Answered: 1 week ago

Question

Have issues been prioritized?

Answered: 1 week ago