Home » C++ Programming » Basic Input/Output » Question
  1. What is the output of this program?
    #include <iostream>
    #include <string>
    #include <sstream>
    using namespace std;
    int main ()
    {
    string str;
    float p = 0;
    int q = 0;
    cout << "Enter item price: ";
    getline (cin, str);
    stringstream(str) >> p;
    cout << "Enter item quantity: ";
    getline (cin, str);
    stringstream(str) >> q;
    cout << "Total item price: " << p * q << endl;
    return 0;
    }
    1. 100
    2. Compilation Error
    3. Depends on entered value
    4. Runtime Error
    5. Garbage value
Correct Option: C

In this program, We are getting the input on runtime and manipulating the value.



Your comments will be displayed only after manual approval.