Strings


  1. What is the output of this program?












  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    In this program, We are finding the length of the string.


  1. Which header file is used to manipulate the string?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    To use the string class, We have to use #include header file.



  1. How many maximum number of parameters does a string constructor can take?











  1. 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.


  1. Which constant member functions does not modify the string?











  1. 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.



  1. 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;
    }











  1. 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.