Question: In C++ Write a function that accepts two int arrays of the same size. The first array will contain numbers and the second array will

In C++ Write a function that accepts two int arrays of the same size. The first array will contain numbers and the second array will be filled out inside the function. THE FUNCTION SHOULD FIND ALL NUMBERS IN THE ARRAY THAT ARE GREATER THAN OR EQUAL TO THE AVERAGE. You need to design the function. so the output code should be:

(show contents of 1st array)

The numbers that are greater than the average of the first array are: (the numbers)

so if the array is 1 2 3 4 5 . The numbers outputted should be 3 4 and 5 because 15/5=3 and 3 4 and are greater than and equal to 3.

I tried this code but the errors returned were: expression must have a constant value #include using namespace std; void fillArray(int arr1[],int arr2[],int arr_size) { int cnt=0; double avg,sum; for(int i=0;i=avg)//condition to check average { arr2[cnt]=arr1[i]; //assigning value to array 2 cnt++; } } //printing seond array cout<<"Second array is: "; for(int i=0;i>arr_size; int arr1[arr_size],arr2[arr_size]; cout<<"Enter the element: "; for(int i=0;i>arr1[i]; } fillArray(arr1,arr2,arr_size); }

also this code is incomplete:

#include using namespace std;

// function declaration void fun(int arr1[], int arr2[], int size){

cout<<"Content of 1st array: "<

// taking input for 2nd array from user cout<<" Enter "<>arr2[i];

cout<<" Content of 2st array: "<

int main(){

// declaring two array of size 6 and initializing first array with some value int arr1[] = {1,2,3,4,5,6}; int arr2[6];

// calling function fun(arr1, arr2, 6);

return 0; }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!