Ask Question
4 August, 21:16

You have the following code: string name; cout <> name; If a user enters "Mary Smith" at the prompt for a name, what will name contain after the cin statement

+4
Answers (1)
  1. 5 August, 00:02
    0
    The variable name will contain Mary after the cin statement

    Explanation:

    The standard input statement cin in c+ + does not read an entire line. When it is used, it read a value until it encounters a white space. The getline function should be used when you want to read a string that contains more than one word.

    The code snipet below has been moderated to use a getline ()

    #include

    using namespace std;

    int main ()

    {

    string name;

    cout << "Enter your name : ";

    getline (cin, name);

    cout<<"The name is "<
    return 0;

    }
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “You have the following code: string name; cout name; If a user enters "Mary Smith" at the prompt for a name, what will name contain after ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers