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
s344n2d4d5 [400]
3 years ago
13

Write a function called median, that takes as parameter a full, sorted array of doubles and returns the median of the list. For

a sorted list of odd length, the median is the middle value. For a sorted list of even length, the median is the average of the two middle values. Make an example function call in your main.

Computers and Technology
1 answer:
serg [7]3 years ago
3 0

Answer: Provided in the explanation section

Explanation:

#include <stdio.h>

double median(double array[] , int n)

{

double med;

//if n is even then return average of middle of two element.

if(n%2==0)

med = ( array[(n-1)/2] + array[n/2] ) /2.0 ;

else

med = array[n/2];//if n is odd return middle element.

 

return (med);

}

int main()

{

double array[6] = {1.3,3.5,5,7.7,9.0,11};

//size store size of array.

int size=sizeof(array)/sizeof(double);

//call the median function.

double medvalue =median(array, size);

printf("median is : %lf\n",medvalue);

return 0;

}

//OUTPUT : median is : 6.350000

⇒ Provided is the Image of the code and output.

cheers i hope this helped !!

You might be interested in
The term generally used to describe storage systems that function at high speeds is:
Alinara [238K]
The term to describe storage systems that function at high speeds is primary memory.
6 0
3 years ago
Select the correct answer from each drop-down menu.
lys-0071 [83]

Answer: A and C

Explanation:I did it before

6 0
4 years ago
You cannot be everywhere at once, but your freedom allows you to
Kay [80]
This type of freedom is called dreaming
7 0
3 years ago
You are driving in the right lane of a municipal road the road has three lanes in your direction ahead of you in the lane to you
Mrrafil [7]
Pull Over. Do NOT Try to push the brake or try swerving with the steering wheel. Slowly pull to the side
7 0
3 years ago
Read 2 more answers
​your business has a web server that has suddenly become unresponsive. when you study the server's logs there are a huge number
kvasek [131]
there's a chance the web server could quite possibly be backed up from all the requests and not being cleaned or updated often
8 0
3 years ago
Read 2 more answers
Other questions:
  • How does the use of modules provide flexibility in a structured programming design?
    14·2 answers
  • loop Write a program to read a list of exam scores given as integer percentages in the range 0 to 100. Display the total number
    5·1 answer
  • Given the following adjacency matrix, what is the approximate rank vector after one iteration of the power iteration method (use
    10·1 answer
  • This is not homework but how do you fix this I’ve tried everything
    9·1 answer
  • 1. Caches are important to providing a high-performance memory hierarchy to processors. Below is a list of 32-bit memory address
    7·1 answer
  • Which of these components is a part of the Central Processing Unit (CPU) of a computer?
    11·2 answers
  • Before a program written in c can be executed on a computer, what step is required to be done first?
    7·1 answer
  • Think about the five steps to writing an algorithm. Why is each step necessary?
    6·2 answers
  • What is the appropriate source to find information about an organization?
    12·1 answer
  • We can find out how robots work by looking in detail at the smaller parts. What do we call this?
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!