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 or equal to the average and fill out the second array with these numbers. You need to design the function.
I tried this code but the errors returned were: expression must have a constant value
#include
void fillArray(int arr1[],int arr2[],int arr_size) { int cnt=0; double avg,sum; for(int i=0;i avg=sum/arr_size; //assigning the second array for(int i=0;i //printing seond array cout<<"Second array is: "; for(int i=0;i } int main() { int arr_size; cout<<"Enter the size of array: "; cin>>arr_size; int arr1[arr_size],arr2[arr_size]; cout<<"Enter the element: "; for(int i=0;i }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started