Question: Lab 1 2 . String Class and Exception Handling Name _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

Lab 12. String Class and Exception Handling
Name_________________
Score_________________
Compile the following program, find and correct errors.
#include
#include
using namespace std;
int main()
{
// Ways to instantiate (create) a string object
string str1("Good Morning");
string str2= "Hot Dog";
string str3;
str3=World+ Cup;
string str4=Friend,+ str1;
cout <<"str1 is: "<< str1<< endl;
cout <<"str2 is: "<< str2<< endl;
cout <<"str3 is: "<< str3<< endl;
cout <<"str4 is: "<< str4<< endl;
return 0;
}
Complete the following program, and run the program. (See pgm14-5, pgm14-8)
#include
#include
#include
using namespace std;
int main()
{
string str="aaaaaa" ;
int i;
int n = int(str.length());
cout << "Enter "<>______; // assign a character to str
while(!isalpha(_____))
{
cout<<"Please reenter a letter"<>str.at(i);
}
}
cout<<"The "<< n <<" letters you entered : "<< str <

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!