145k views
0 votes
. Suppose that name is a variable of type string. Write the input statement to read and store the input Brenda Clinton in name

1 Answer

6 votes

Answer:

The program to this question can be given as follows:

Program:

//header file

#include <iostream> //defining header file

using namespace std;

//main

int main() //defining main method

{

string name; //defining main method

cout<<"enter name: "; //print message

getline(cin,name); //using getline method

cout<<"The name you inserted is: "<<name; //print value

return 0;

}

Output:

Please Enter Name: Brenda Clinton

The name you inserted is: Brenda Clinton

Step-by-step explanation:

Firstly the header file is included in the above C++ program code, in the next line the main method is defined, inside this method the string variable is defined which takes value from user-ends.

  • In the above specifies the getline method, which can be referred to as a standard library feature for reading an input stream string or a line. It removes characters from the input stream and applies this to the string object until the character is delimited.
  • After taking input the print method "cout" is used to print "name" variable value.

User Drew Dello Stritto
by
8.4k points
Welcome to QAmmunity.org, where you can ask questions and receive answers from other members of our community.