adplus-dvertising
frame-decoration

Question

What is the output of this program?
    #include <iostream>
    #include <string>
    #include <sstream>
    using namespace std;
    int main ()
    {
        string mystr;
        float price = 0;
        int quantity = 0;
        cout << "Enter price: ";
        getline (cin, mystr);
        stringstream(mystr) >> price;
        cout << "Enter quantity: ";
        getline (cin, mystr);
        stringstream(mystr) >> quantity;
        cout << "Total price: " << price * quantity << endl;
        return 0;
    }

a.

50

b.

Depends on value you enter

c.

Error

d.

None of the mentioned

Answer: (b).Depends on value you enter

Engage with the Community - Add Your Comment

Confused About the Answer? Ask for Details Here.

Know the Explanation? Add it Here.

Q. What is the output of this program?

Similar Questions

Discover Related MCQs

Q. How many parameters are there in getline function?

Q. What can be used to input a string with blankspace?

Q. When will the cin can start proceessing of input?

Q. Which is used for formatting purpose in c++?

Q. How many number of spaces should be set in default tab?

Q. What can be improved by formatting the source code?

Q. Choose the correct formatted code.

Q. Which function allows you to set minimum width for the next input?

Q. What is the use of the function “showbase”?

Q. Which operator is used to insert the data into file?

Q. Which function is used to position back from the end of file object?

Q. How many objects are used for input and output to a string?

Q. Which member function is used to determine whether the stream object is currently associated with a file?

Q. Which header file is used for reading and writing to a file?

Q. Which one is always faster in writing on C++?

Q. How many tests are available in read and write operations?

Q. What will act as a intermediate between i/o operations and physical file?

Q. By using which function does the buffer are automatically flushed?

Q. How many parameters are available in the function setbuf?

Q. What is the main feature of locale in C++?