Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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:

image text in transcribed

#include define N 10 void max min (int a[], int n, int *max, int *min); int main (void) int b[n], 1, big, small; printf("Enter %d numbers: ", N); PLEASE COMPLETE THE MAIN HERE return 0: void max_ min(int al], int n, int *max, int *min) int *p; ELEASE COMPLETE THE FUNCTION HERE

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

Students also viewed these Databases questions