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.