Home » C++ Programming » Strings » Question
  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. my life
    2. Coding is my life
    3. Coding is my
    4. Compilation Error
    5. None of these
Correct Option: C

In this program, We are resizing the string by adding + and then we are resizing it to 13.



Your comments will be displayed only after manual approval.