Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

- Given the following string variable, write a statement that would insert \"int

ID: 3635738 • Letter: #

Question

- Given the following string variable, write a statement that would insert "interesting" before the word example
in str1.

string str1 = "Here is an example string";

- Given the following string variable, write a statement that would output the number of characters in str1.

string str1 = "Here is an example string";

- Create an output format statement which would generate lines in the table which appear as shown below. The Element Name Field displays an element name contained in the name variable. YYY displays an integer value from the anum variable which ranges from 1 thru 109 and should be left justified. XXX.XXXX displays an atomic weight value from the aweight variable which ranges from 1.0000 to 268.0000 and should be right justified. Use the variables shown below in your output statements.

Element Name Field..YYY....XXX.XXXX

char name[15]; int anum; double aweight;


Explanation / Answer

Dear user,

The following string variable, write a statement that would insert "interesting" before the word example answer is:

string str1 = "Here is an example string";

int index=str1.find("example");

str1.insert(index,"interesting ");



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

The statement that would output the number of characters in str1:

It is possible by using length function.

The answer is:

cout <<"Number of characteres in str1: " << str1.length() ;

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

//An output format statement answer is:

#include <iomanip>

   cout <<setw(25)<<right<<name<<setw(3)<<right<<age<<setw(8)<<right<<setprecision(2)      <<salary<<endl;