Question: Write a C++ program that reads a set of numerical grades from the keyboard into an array. The maximum number of grades to be entered

Write a C++ program that reads a set of numerical grades from the keyboard into an array. The maximum number of grades to be entered is 50, and data entry should be terminated when a negative number is entered. Have your program sort and print the grades in descending order. Code this program using vectors and the Standard Template Library. The STL has a built in sort function but this sorts in ascending order. The problem asks for descending order. ** The solution in the textbook solutions section does not use vectors or the STL. ** Here is the way they do it, just need some help tweaking this code to use vectors and the STL to sort in descending order:

Write a C++ program that reads a set of numerical grades from

100 Ett include iostream #include Kvector 11 12 using namespace std 13 14 int main() 15 int grades[501; 16 int i, count 0, temp; 17 18 cout "Please Enter The Grades You Want Sorted: An endl 19 21 I for (i e; i 50; i++) 22 cin grades [i] 23 24 if (grades[i] 0) 25 26 rea 27 count++; 28 30 31 cout endl; 32 33 for (int j 0; j k count; j++) 34 for (int k 0; k count j; k++) 35 36 37 I if (grades[k] grades k 11) 38 temp grades [k 11; 39 grades [k 11 grades [k] 400 41 grades [k] temp 42 45 cout "The Sorted Grades Are: An endl 46 47 48 for (i e, i k count i++) {cout grades [i] 49 50 cout

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!