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

Question
Asked Oct 5, 2019
1053 views

Assign secretID with firstName, a space, and lastName. Ex: If firstName is Barry and lastName is Allen, then output is:

Barry Allen

#include <iostream>
#include <string>
using namespace std;

int main() {
string secretID;
string firstName;
string lastName;

cin >> firstName;
cin >> lastName;

/* Your solution goes here */

cout << secretID << endl;
return 0;
}

Please help me with this string operations problem.

check_circle

Expert Answer

star
star
star
star
star
1 Rating
Step 1

To correct the given program code to assign the secretID as firstName,  space, and lastName, as shown below:

Barry Allen

Step 2

Correct program code:

 

#include <iostream>

#include <string>

using namespace std;

int main()

{

string secretID;

string firstName;

string lastName;

cin >> firstName;

cin >> lastName;

//assigning the value of firstName and lastName to the secretID with a space

secretID=firstName+" "+lastName;

/* Your solution goes here */

cout << secretID << endl;

return 0;

}

Step 3

Output of the above given program code:

...
help_outline

Image Transcriptionclose

Barry Allen Barry Allen

fullscreen

Want to see the full answer?

See Solution

Check out a sample Q&A here.

Want to see this answer and more?

Solutions are written by subject experts who are available 24/7. Questions are typically answered within 1 hour.*

See Solution
*Response times may vary by subject and question.
Tagged in

Engineering

Computer Science

Programing Language

Related Computer Science Q&A

Find answers to questions asked by student like you
Show more Q&A
add
question_answer

Q: Please help me solve this problem

A: Note: The Python program is coded as the user requirements.In Python, code indentation is very impor...

question_answer

Q: What are the Windows 2016 "flavors"?

A: Windows Server 2016 comes in 3 flavors, which are, Server Core (no GUI), Server with Desktop Experie...

question_answer

Q: the book is "First Course on Fuzzy Theory and Applications"

A: The formula for calculating the Hamming distance (d) of fuzzy set:

question_answer

Q: 11.7: Customer AccountsWrite a program that uses a structure to store the following data about a cus...

A: Program plan:Include the required header files.Define the structure “customerAccount”Declare the req...

question_answer

Q: Question: Write a program that prompts the user to enter the number of students and each student's s...

A: Solution:The python program has the following algorithm:Prompt and read the total number of students...

question_answer

Q: Annotate the following MIPS instructions to indicate source registersand destination registers. A so...

A: Annotations for the MIPS instructions mentioned in the question are given below-add $s1, $t2, $t3Add...

question_answer

Q: create a file in c++. Download the attached CreateRandomNumbersFile.cpp file, open it in Dev C++, an...

A: Program Instructions:Include necessary header files, declare local variables, and display a hello me...

question_answer

Q: Write an application starting with ProjectTemplate. Name the class AgeCalcApp. The app needs to prom...

A: To write an application name ProjectTemplate with the class name AgeCalcApp. This application prompt...

question_answer

Q: What is the difference between a trap and an interrupt?

A: DefinitionTrap is prompted by a user program to invoke Operating System functionality.Interrupt is t...