Answer to Question #219204 in C++ for Kojo

Question #219204

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-20T17:01:12-0400
#include <iostream>


#include <string>


using namespace std;

int main() {


  string firstName;


  string lastName;


  cout<<"\nEnter first Name: ";
  cin>>firstName;
  cout<<"\nEnter last Name: ";
  cin>>lastName;
  cout<<lastName<<","<<firstName;


  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