Consider the following statements: string str = \"There are 10 types of people:
ID: 3568810 • Letter: C
Question
Consider the following statements:
string str = "There are 10 types of people: those who understand binary, and those who do not understand it.";
string str1;
string::size_type index;
What is the output of the following statements? (NOTE: assume that all parts A, B, C, D, and E are independent of each other.)
A. index = str.find("understand");
str1 = str.substr(10, index-4);
cout << str1 << endl;
cout << str1.size() << endl;
Write or type the output below:
B. cout << str.substr(7, 8) << endl;
Write or type the output below:
C. string :: size_type ind = str.find('f');
string s = str.substr(ind + 4, 9);
cout << s << endl;
Write or type the output below:
D. str.clear();
cout << str.insert (0, "Dan is the best!") << endl;
Write or type the output below:
E. str.erase(10, 2);
str.insert(10, "one and zero");
cout << str << endl;
Write or type the output below:
Explanation / Answer
A)
10 types of people: those who unders
36
B)
re 10 ty
C)
ople: tho
D)
Dan is the best!
E)
There are one and zero types of people: those who understand binary, and those who do not understand it.