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

Need help with the following: Complete the function to replace any period by an

ID: 3689112 • Letter: N

Question

Need help with the following: Complete the function to replace any period by an exclamation point. Ex: "Hello. I'm Miley. Nice to meet you." becomes: "Hello! I'm Miley! Nice to meet you!" #include #include using namespace std; void MakeSentenceExcited(char* sentenceText) { /* Your solution goes here */ } int main() { const int TEST_STR_SIZE = 50; char testStr[TEST_STR_SIZE]; strcpy(testStr, "Hello. I'm Miley. Nice to meet you."); MakeSentenceExcited(testStr); cout << testStr << endl; return 0; }

Explanation / Answer

#include <iostream>
#include <cstring>
using namespace std;
void MakeSentenceExcited(char* sentenceText)
{
for(int i=0;sentenceText[i]!='';i++)
{
if(sentenceText[i]=='.')
{
sentenceText[i]='!';
}
}
return;
}
int main()
{
const int TEST_STR_SIZE = 50;
char testStr[TEST_STR_SIZE];
strcpy(testStr, "Hello. I'm Miley. Nice to meet you.");
MakeSentenceExcited(testStr);
cout << testStr << endl;
return 0;
}

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