12. For a program to use the string class, it must contain the #include <string> directive.
Indicate the answer choice that best completes the statement or answers the question.
13. What function can be used to get string input from the keyboard?
14. Which string class function can be used to replace a sequence of characters in a string variable with another sequence
of characters.
15. What is assigned to newStr after the following code is executed?
string orgStr = “Hello there!”;
string newStr = orgStr.substr(1, orgStr.length() – 1);
16. In order to use the string data type in a program, what code must be in your program?
a #include <iostream> directive
a using <iostream> statement
a #include <string> directive
a using <string> statement
17. What will the value of newStr be after the following code is executed?
string newStr = “13 Mockingbird Lane”;
newStr.insert(1, “31”);
18. Which of the following statements gets a string from the keyboard until the newline character is encountered and
assigns the string to a variable named myStr?
getline(cin, myStr, ‘/n’);
getline(myStr, cin, ‘\n’);
19. To remove one or more characters located anywhere in a string variable, which string class function would be used?
20. Which of the following is the escape sequence that represents the newline character?