Write a program that dynamically allocates a vector large enough to hold any num
ID: 441942 • Letter: W
Question
Write a program that dynamically allocates a vector large enough to hold any number of scores the user wishes to enter. . Once all the scores are entered, the vector should be passed to a function that sorts them in ascending order. Another function should then be called that calculates the average score. The program should display sorted list of scores and average, with appropriate headings. Please write code that works, second time posting this.Explanation / Answer
#include #include #include using namespace std; vector vector_sort(vector matrix) { sort (matrix.begin(), matrix.end()); return matrix; } int main() { int n; int x; double mean=0; vector scores; coutn; for (int i=0; i>x; scores.push_back(x); } scores = vector_sort(scores); coutRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.