Question: Complete the function to replace any period by an exclamation point. Ex: Hello. I ' m Miley. Nice to meet you. becomes: Hello! I '

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(string& sentenceText)
{
//Type function here with explanation
}
int main(){
string testStr;
getline(cin, testStr);
MakeSentenceExcited(testStr);
cout testStr;
return 0;
}
I cannot seem to get mine to work. this is what I have.
#include
#include
using namespace std;
void MakeSentenceExcited(string &testStr)
{
int sizeOfString = size(testStr);
for (char a:testStr)
{
if (a =='.')
{
a ='!';
}
}
}
int main()
{
string testStr;
getline(cin, testStr);
MakeSentenceExcited(testStr);
return 0;
}
You can only edit the function using C++ and nothing else.
 Complete the function to replace any period by an exclamation point.

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!