1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
ANEK [815]
3 years ago
8

Write a function that determines the maximum and minimum values from a one-dimensional array. Assume that the corresponding func

tion prototype statement is void ranges(int x[], int npts, int *max_ptr, int *min_ptr) where npts contain the number of values in array x, and max_ptr and min_ptr are pointers to the variables in which to store the maximum and minimum values in the array.
Computers and Technology
1 answer:
erica [24]3 years ago
8 0

Answer:

void ranges(int x[], int npts, int *max_ptr, int *min_ptr)

{

   *max_ptr=*min_ptr=x[0];

   for(int i=1;i<npts;i++)

   {

       if(x[i]>*max_ptr)        //this will put max value in  max_ptr

           *max_ptr=x[i];

       if(x[i]<*min_ptr)  //this will  put min value in min_ptr

           *min_ptr=x[i];

   }

}

Explanation:

The above function can be called like :

                                    ranges(x,n,&max,&min);  

where x is array and n is number of elements and max and min are address of variables where maximum and minimum values to be stored respectively.

You might be interested in
Which control program flow options runs to the end of the code block and resumes the break mode at the statement that follows?
Aliun [14]

Answer:

Step Out

Explanation:

In the field of computer science, the control flow or the flow of control is defined as the order where the individual statements, \text{function calls} or instructions of a program are \text{evaluated or executed. }

The Step Out control flow program runs to the \text{end of the code block} and it resumes the \text{break mode} at the statement that it follows.

5 0
3 years ago
How was kapilvastu named​
mixas84 [53]

Answer:  Kapilvastu was named after Vedic sage Kapilamuni

4 0
3 years ago
BIm computer class I need answers please
egoroff_w [7]

Answer:

I think the 3RD

Explanation:

The  reason why I think that is because the other once are not written correctly.

8 0
3 years ago
Read 2 more answers
Small robots that can move around on the surface of a planet are called space shuttles.
PolarNik [594]

b:false because space shuttles orbit around a planet in outer space



3 0
3 years ago
Read 2 more answers
Please help im not good at computer class ​
Veronika [31]

Answer:

W.

Explanation:

4 0
3 years ago
Read 2 more answers
Other questions:
  • If r is an instance of the above Person class and oddNum has been declared as a variable of type boolean, which of the following
    8·1 answer
  • Write a short program that allows the user to input a positive integer and then
    5·1 answer
  • The cylinder head and engine block are completely sealed by a A. valve seal. B. head gasket. C. intake manifold. D. spark plug
    11·2 answers
  • Andy, a developer, is designing a new program. Which tool should Andy use to help him complete his task?
    13·1 answer
  • The best place to start when you are looking for information about a device or an application is the ____ of the company that ma
    14·1 answer
  • What is not true of credit scores?
    11·1 answer
  • What is the most effective way to demonstrate being prepared for an interview?
    13·1 answer
  • Can someone help me with python
    10·1 answer
  • Which option is typically only used when utilizing self joins?
    8·1 answer
  • How will technology help people with disabilities become more transportation independent?.
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!