Answer to Question #219127 in C++ for Bless

Question #219127

Using the code stub below, write a program that reads a person's first and last names, separated by a space. Then the program outputs last name, comma, first name. End with newline.

Example output if the input is: Akua Mperey

Mperey, Akua

#include <iostream>

#include <string>

using namespace std;


int main() {

  string firstName;

  string lastName;

  /* Your solution goes here */

  return 0;

}

1
Expert's answer
2021-07-21T16:38:24-0400
#include <iostream>

#include <string>

using namespace std;

 int main() 

 {

 string firstName;

 string lastName;

cout<<"Enter First Name ";

getline(cin,firstName);

cout<<"Enter Last Name ";

getline(cin,lastName);

cout<<lastName<<", "<<firstName<<"\n";

 return 0;

}


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS