Question
Write a program that finds minimum and maximum numbers in the elements of an array of size 10 (You can define a constant N at
Write a program that finds minimum and maximum numbers in the elements of an array of size 10 (You can define a constant N at the beginning as array size 10)
Example:
Enter 10 numbers: 1 13 12 11 9 99 80 12 8 12
Largest: 99
Smallest: 1
You need to use pointers for writing the program. We name the function max_min whose prototype is given below:
void max_min(int a[], int n, int *max, int *min);
Note: You could use *a instead of a[] in function prototype.
Note that this is a void function so no return value is expected. We call the function using this inmain, assuming we have an array b of size N=10: max_min(b, N, &big, &small);
Hint: This is the beginning of a for loop which you can use in your function (note that a means &a[0] and a+n means &a[n] , do not forget the asterisks in your function for min and max)
for (p = a; p
if (*p > *max)
*max = *p;
.
.
.
}
This is what the program should look like, Please fill in where the red asterisks are:
#includeStep 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