Which header file should be included to work with strings in C++?
What is the maximum number of characters that can be stored in a string object in C++?
1 Crore+ students have signed up on EduRev. Have you? Download the App |
Which of the following is a valid way to concatenate two strings in C++?
What is the output of the following code snippet?
string str = "Hello";
cout << str[2];
Which function is used to extract a substring from a string in C++?
Which of the following is not a valid way to compare two strings in C++?
What is the output of the following code snippet?
```cpp
string str1 = "Hello";
string str2 = "World";
cout << str1 + " " + str2;
```
What is the output of the following code snippet?
```cpp
string str = "OpenAI";
cout << str.substr(2, 3);
```
What is the output of the following code snippet?
```cpp
string str = "Hello";
str[1] = 'X';
cout << str;
```
What is the output of the following code snippet?
```cpp
string str = "Hello World";
cout << str.find("World");
```
What is the output of the following code snippet?
```cpp
string str = "Programming";
cout << str.size() << " " << str.length();
```
What is the output of the following code snippet?
```cpp
string str = "Hello World";
reverse(str.begin(), str.end());
cout << str;
```
What is the output of the following code snippet?
```cpp
string str1 = "Hello";
string str2 = "Hello";
if (str1.compare(str2) == 0)
cout << "Equal";
else
cout << "Not equal";
```
What is the output of the following code snippet?
```cpp
string str = "Hello World";
str.erase(5, 5);
cout << str;
```
What is the output of the following code snippet?
```cpp
string str = "Hello World";
str.insert(6, "C++ ");
cout << str;
```
What is the output of the following code snippet?
```cpp
string str = "Hello World";
str.replace(6, 5, "C++");
cout << str;
```