Write a program that will have a predefined array and then asks the user to ente
ID: 3734582 • Letter: W
Question
Write a program that will have a predefined array and then asks the user to enter an integer value call it number. Then write the following functions to display: .All values larger than number found in the array. Here is the function prototype: o void displayGreaterThan int], int) .All values smaller than number found in the array. Here is the function's prototype: o void displaySmallerThan(intl). int) o void display ArTayContent int[]): o void displayLargetValue int ): . All values in the array. Here is the function's prototype: The largest value in the array. Here is the function's prototype The smallest value in the array. Here is the function's prototype: void displayStnallestValue(int[]); To help you getting started use ArrayManipulations.qpp, which includes the prototypes of all the functions as well as the implementation of displayGreaterThan(intl, int) function. View 172
Explanation / Answer
The functions implementation would be
void displaySmallerThan(int values[],int n)
{
for(int i=0;i<SIZE;i++)
if(values[i]<n)
cout<<values[i]<<" ";
cout<<endl;
}
void displayArrayContent(int arr[])
{
for(int i=0;i<SIZE;i++)
cout<<arr[i]<<" ";
cout<<endl;
}
void displayLargestValue(int arr[])
{
int m=arr[0];
for(int i=0;i<SIZE;i++)
m=max(arr[i],m);
cout<<m<<endl;
}
void displaySmallestValue(int arr[])
{
int m=arr[0];
for(int i=0;i<SIZE;i++)
m=min(arr[i],m);
cout<<m<<endl;
}
Do give a thumbs up and in case there are doubts leave a comment.
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.