Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Secrets Of Analytical Leaders Insights From Information Insiders

Authors: Wayne Eckerson

1st Edition

1935504347, 9781935504344

More Books

Students also viewed these Databases questions