Complete the function CheckAll() that takes one string parameter and one character parameter. The function returns true

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

Complete the function CheckAll() that takes one string parameter and one character parameter. The function returns true

Post by answerhappygod »

Complete the function CheckAll() that takes one string parameterand one character parameter. The function returns true if all thecharacters in the string are not equal to the character parameter.Otherwise, the function returns false.
Ex: If the input is ddpz p, then the output is:
False, at least one character is equal to p.
Here is the template of the problem, please use it:
#include <iostream>using namespace std;
bool CheckAll(string inputString, char x) {
#include <iostream>#include<vector>using namespace std;
//Code for PickIndices functionvoid pickIndices(string a, char b, vector<int>&results){int i=0;for(i=0; i< a.size() ; i++){if(a==b){results.push_back(i);}}}
}
int main() { string inputString; char x; bool result;
cin >> inputString; cin >> x;
result = CheckAll(inputString, x);
if (result) { cout << "True, all thecharacters are not equal to " << x << "." <<endl; } else { cout << "False, atleast one character is equal to " << x << "." <<endl; }
return 0;}
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply