Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a program that asks the students to enter the number of courses they each have and then, store it a vector. The program should

Write a program that asks the students to enter the number of courses they each have and then, store it a vector. The program should contain a function, findMedian() that accepts as arguments a vector containing the number of courses. The function returns the median value of the number of courses to the main().

The program has additional requirements as follows:

The program should ask number of users as input to decide the size of the vector.

Do not use the '[ ]'operator to access the elements of the vector.

Use pass-by-reference to pass the vector to the function findMedian().

MEDIAN: a set of values sorted in ascending or descending order, its median

is the middle value. If the set contains an even number of values, the median is the

mean, or average, of the two middle values.

Example output: Case 1: odd number of elements in the vector

5 2 1 4 5

The median is: 4

Example output: Case 2: even number of elements in the vector

3 4 2 5

The median is: 3.5

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

Recommended Textbook for

More Books

Students also viewed these Databases questions