Strings
- What is the output of this program?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: C
In this program, We are finding the length of the string.
- Which header file is used to manipulate the string?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: D
To use the string class, We have to use #include header file.
- How many maximum number of parameters does a string constructor can take?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: B
string( other_string, position, count ). It is a type of constructor for the string.
- Which constant member functions does not modify the string?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: C
Because bool empty is a constant member function, So it can’t be modified.
- What is the output of this program?
#include <iostream>
#include <string>
using namespace std;
int main ()
{
string s ("Coding is my life");
unsigned sz = s.size();
s.resize (sz + 2, '+');
s.resize (13);
cout << s << '\n';
return 0;
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: C
In this program, We are resizing the string by adding + and then we are resizing it to 13.