Answer:
See explaination
Explanation:
#include <iostream>
using namespace std;
/* Type your code for the function findWithinThreshold here. */
void findWithinThreshold(int argSource[], int argsSourseSize, int argThreshold, int argTarget[], int &argsTargetSize)
{
argsTargetSize = 0;
for (int i = 0; i < argsSourseSize; i++)
{
if (argSource[i] <= argThreshold)
argTarget[argsTargetSize++] = argSource[i];
}
}
/* Type your code for the function findWithinLimits here. */
void findWithinLimits(int argSource[], int argsSourseSize, int argLowLimit, int argHighLimit,int argTarget[],int &argTargetCount)
{
argTargetCount = 0;
for (int i = 0; i < argsSourseSize; i++)
{
if (argSource[i]>=argLowLimit && argSource[i] <= argHighLimit)
argTarget[argTargetCount++] = argSource[i];
}
}
int main() {
const int MAX_SIZE = 100;
int source[MAX_SIZE]; //integer array source can have MAX_SIZE elements inside it ;
// user may chose to use only a portion of it
// ask the user how many elements are going to be in source array and
// then run a loop to get that many elements and store inside the array source
int n;
cout << "How many elements: ";
cin >> n;
for (int i = 0; i < n; i++)
{
cout << "Enter " << (i + 1) << " element: ";
cin >> source[i];
}
int threshold, lower_limit, upper_limit;
/* Type your code to declare space for other required data like
target array (think how big it should be)
threshold
lower limit
upper limits
as well as the variable that will bring back the info regarding how many elements might be in target array
*/
int *target = new int[n];
int targetCount;
cout << "\nEnter thresold value: ";
cin >> threshold;
/* Type your code to get appropriate inputs from the user */
cout << "\nEnter lower limit: ";
cin >> lower_limit;
cout << "\nEnter upper limit: ";
cin >> upper_limit;
/* Type your code here to call/invoke the function findWithinThreshold here.. */
/* Type your code to print the info in target array - use a loop and think about how many elements will be there to print */
findWithinThreshold(source, n, threshold, target, targetCount);
cout << "\nElement in the threshold = " << targetCount << endl;
for (int i = 0; i < targetCount; i++)
cout << target[i] << "\n";
/* Type your code here to call/invoke the function findWithinLimits here.. */
/* Type your code to print the info in target array - use a loop and think about how many elements will be there to print */
findWithinLimits(source, n, lower_limit, upper_limit, target, targetCount);
cout << "\n\nElements with in the " << lower_limit << " and "<<upper_limit<<endl;
for (int i = 0; i < targetCount; i++)
cout << target[i] << " ";
cout << endl;
system("pause");
return 0;
}