for the following strings in c string first string middle s
for the following strings in c++
string first ()
string middle()
string last ()
how can I prompt the user to put in there first name then middle name then last name.Then make a copy of each of them and put them in one string called name ().Finally display the string.
Solution
#include <iostream>
using namespace std;
int main()
{
//Declare the strings used
string first, middle, last, name;
//Prompt for input
cout << \"Enter first name: \";
getline (cin, first);
cout << \"Enter middle name: \";
getline (cin, middle);
cout << \"Enter last name: \";
getline (cin, last);
// Sting concat
name = first + middle + last;
//Final string
cout << \" Full name : \"<< name << endl;
return 0;
}
