Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Systems On GPUs In Databases

Authors: Johns Paul ,Shengliang Lu ,Bingsheng He

1st Edition

1680838482, 978-1680838480

More Books

Students also viewed these Databases questions

Question

What is the normal balance of the owners withdrawals account?

Answered: 1 week ago

Question

CompTia Sec + Final Assessment nmap switches examples

Answered: 1 week ago