Complete the code to declare a string variable named 'name'.
std::string [1] = "Alice";
The variable name for the string is 'name' as required.
Complete the code to get the length of the string 'word'.
int length = word.[1]();The correct method to get the length of a string in C++ is 'length()'.
Fix the error in the code to access the first character of the string 'text'.
char firstChar = text[1];To access a character by index in a string, use square brackets [].
Fill both blanks to create a substring from 'text' starting at index 2 with length 4.
std::string sub = text.[1]([2], 4);
The method to get a substring is 'substr'. The starting index is 2.
Fill all three blanks to create a map of words to their lengths for words longer than 3 characters.
std::map<std::string, int> lengths; for(const auto& {{BLANK_3}} : words) { if({{BLANK_3}}.[2]() > 3) { lengths[{{BLANK_3}}] = {{BLANK_3}}.[2](); } }
We map each 'word' to its length using 'word.length()' iterating over 'word' in 'words'.
