Question
#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
Posted under Object Oriented Programming Using C++
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?
View solution
Q. What can be used to input a string with blankspace?
View solution
Q. When will the cin can start proceessing of input?
View solution
Q. Which is used for formatting purpose in c++?
View solution
Q. How many number of spaces should be set in default tab?
View solution
Q. What can be improved by formatting the source code?
View solution
Q. Choose the correct formatted code.
View solution
Q. Which function allows you to set minimum width for the next input?
View solution
Q. What is the use of the function “showbase”?
View solution
Q. Which operator is used to insert the data into file?
View solution
Q. Which function is used to position back from the end of file object?
View solution
Q. How many objects are used for input and output to a string?
View solution
Q. Which member function is used to determine whether the stream object is currently associated with a file?
View solution
Q. Which header file is used for reading and writing to a file?
View solution
Q. Which one is always faster in writing on C++?
View solution
Q. How many tests are available in read and write operations?
View solution
Q. What will act as a intermediate between i/o operations and physical file?
View solution
Q. By using which function does the buffer are automatically flushed?
View solution
Q. How many parameters are available in the function setbuf?
View solution
Q. What is the main feature of locale in C++?
View solution
Suggested Topics
Are you eager to expand your knowledge beyond Object Oriented Programming Using C++? We've curated a selection of related categories that you might find intriguing.
Click on the categories below to discover a wealth of MCQs and enrich your understanding of Computer Science. Happy exploring!
Operating System
Dive deep into the core of computers with our Operating System MCQs. Learn about...
Software Engineering
Learn about the systematic approach to developing software with our Software...