What will the following statements display to the screen cas

What will the following statements display to the screen (case-sensitive):

       string msg = \"C++ is the best\";
       msg.replace(msg.find(\"C++\"), 3, \"CBU\");
       msg.append(\"!\");
       cout << msg;

Solution

Output is :

CBU is the best!

How?

msg.find(\"C++\") finds the position of C++ in string msg.

msg.replace(msg.find(\"C++\"), 3, \"CBU\"); replace the string with 3 character after the position of \"C++\" in msg variable. so C++ to CBU

msg.append(\"!\"); appends \'!\' to end of string

What will the following statements display to the screen (case-sensitive): string msg = \

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site