Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

C++ write the function for these questions (using the while loop) these two ques

ID: 3871251 • Letter: C

Question

C++ write the function for these questions (using the while loop)

these two questions are related

The output should same as example

When comparing sentences we are often not interested in differences in case (UPPERCASE vs lowercase) or punctuation. For this problem, you will be writing a function that takes two string parameters- sentence and punctuation and returns the same string in lowercase (remember the built-in tolower function) and with given punctuation removed. You must use nested loops. The built lowerNOPunctuation returns a string and takes a two strings as parameters : string lowerNOPunctuation(string str, string punch) { 1/Your code here Example output string str = "Hello, my name is Inigo Montoya. You killed my father. Prepar string punct = "., t!?"; string newStr a lowerNOPunctuation(str, punct) cout

Explanation / Answer

str is global

void lowerNoPunctuation(string str, string p){

int i,j;

for(i=0;i<p.length();i++){

int b = str.length();

for(j=0;j<b;j++){

if(str[j] == p[i]) str.erase(j,1);

b = str.length()

}

}

for(i=0;i<str.length();i++) if(isupper(str[i])) str[i] = (char)((int)str[i]+32);

}

int countWord(string str, string match){

int count = 0;

size_t nPos = str.find(match, 0); // fist occurrence

while(nPos != string::npos){

count++;

nPos = str.find(match, nPos+1);

}

return count;

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote