Assign secretID with firstName, a space, and lastName. Ex: If firstName is Barry and lastName is Allen, then output is:
Barry Allen
#include
#include
using namespace std;
int main() {
string secretID;
string firstName;
string lastName;
cin >> firstName;
cin >> lastName;
/* Your solution goes here */
cout << secretID << endl;
return 0;
}

Respuesta :

Answer:

Here is the statement that is to be added in the given program:

secretID=firstName+" "+lastName;

This statement has an operator + which is used to concatenate two strings i.e. firstName and lastName. The string stored in firstName is concatenated with the string stored in lastName with a space " " between both the string which is specified in the statement. So there are two + operators used in the above statement, one is used to concatenate firstName string followed by a space and the other is used to concatenate lastName string following a space, thus as a whole creating a new string by concatenating firstName and lastName strings together with a space between them.

Explanation:

Here is the complete program:

#include <iostream> //used for input output functions

using namespace std; //to identify objects like cin cout

int main() { //start of main function

string secretID; // declares a string type variable

string firstName; //declares a string type variable to hold first name

string lastName;//declares a string type variable to hold last name

cin >> firstName; //reads first name from user

cin >> lastName; //reads last name from user

secretID=firstName+" "+lastName; //concatenates first and last names with a space between

cout << secretID << endl; //displays the concatenated string

return 0;}

Suppose the user enters "Barry" in firstName and "Allen" in lastName. So the output of the above program is:

Barry Allen

The screenshot of the program along with its output is attached.

Ver imagen mahamnasir

Answer:

secretID = firstName;

     char spaceChar = ' ';

     secretID = secretID + spaceChar;

     secretID = secretID.concat(lastName);

Explanation:

Ver imagen DarthVaderBarbie