0

here are the question:

#include<iostream>
#include<string>
using namespace std;
int main()
{
string strWords1, strWords2;
strWords1 = "To Be Or Not To Be";
strWords2 = "That Is The Question!";

return 0;
}
---------------------------------------------
Modify the program to include:
a) a statement to replace the last character in the strWords2 with '?'
b) a statement to display length of the strWords2
c) a statement to display fourth word in strWords1
d) a statement to find the position of 'N' in strWords1
e) a statement to swap strWord2 and srtWords1

----------------------------------

Here are what i have done, but i'm not sure it is correct..plz help me..i've tried this many times...

#include<iostream>
#include<string>

using namespace std;

int main()
{
int length =21;
string strWords1, strWords2;
strWords1 = "To Be Or Not To Be";
strWords2 = "That Is The Question!";


strWords1.insert(18, "?");
cout<<strWords1<<endl;


cout<<endl<<endl;

strWords2.length();
cout<<length<<endl;


strWords2.swap(strWords1);
cout<<"strWords2= "<<strWords2<<endl;
cout<<"strWords1= "<<strWords1<<endl;

cout<<endl<<endl;

return 0;

}

2
Contributors
1
Reply
3
Views
11 Years
Discussion Span
Last Post by iamthwee
0

>Here are what i have done, but i'm not sure it is correct..plz help me..i've tried this many times...


If it spits out what you expect then it probably works, if it does not then no.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.