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;

}

Member Avatar for iamthwee

>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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.