Home » C++ Programming » Classes & Objects » Question
  1. What is the output of this program?
    #include <iostream>
    #include <sstream>
    using namespace std;
    int main()
    {
    stringstream strstream(ios :: in | ios :: out);
    std :: string data("The double value is : 12.25 .");
    strstream.str(data);
    strstream.seekg(-5, ios :: end);
    double value;
    strstream >> value;
    value = value*value;
    strstream.seekp(-5,ios::end);
    strstream << value;
    std :: string new_value = strstream.str();
    cout << new_value;
    return 0;
    }
    1. 12.25
    2. Compilation Error
    3. 120.0625
    4. Runtime Error
    5. None of these
Correct Option: C

In this program, We have used the string hierarchy to compute the square of the number.



Your comments will be displayed only after manual approval.