Question: // Make it work bool contains(string s, char c) // This code is suspect { for (int k = s.size() - 1; k >= 0;

// Make it work bool contains(string s, char c) // This code is suspect { for (int k = s.size() - 1; k >= 0; k--) { if (s[k] == c) return true; else return false; } } int main () // This main function is CORRECT!!! { if (contains("xyz", 'x')) cout << "x" << endl; else cout << "no x" << endl; if (contains("xyz", 'y')) cout << "y" << endl; else cout << "no y" << endl;; return 0; }

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!