Question
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
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