Changes/Additions to the Exam 2 Practice Problem Solutions: ----------------------------------------------------------- PROBLEM 2: ---------- Refer to this solution instead: string s; unsigned int i=0, j=0; while (j != s.size()) { if (s[j] != 'C' && s[j] != 'c'){ s[i] = s[j]; // copy from location j to i in s i++; j++; } else j++; // increment just j, thereby skipping the 'C' or 'c' } s.erase(s.begin()+i, s.end()); // erase rest of s (from i to end) PROBLEM 10: ----------- Should have a "return mode;" at the end of the function. Also, here is a more efficient version: int find_mode(vector const& values) { vector copy = values; sort(copy.begin(), copy.end()); int mode = copy[0]; int mode_count = 1; int current_count = 1; for (unsigned int i=1; i mode_count && copy[i] != mode) { mode = copy[i]; mode_count = current_count; } else if(current_count > mode_count) { // i.e. copy[i] == mode mode_count++; } } else current_count = 1; } return mode; }