Write a program that reads a person's first and last names separated by a space, assuming the first and last names are both single words. Then the program outputs last name, first name. End with newline. Example output if the input is: Maya Jones Jones, Maya
Write a program that reads a person's first and last names separated by a space, assuming the first and last names are both single words. Then the program outputs last name, first name. End with newline. Example output if the input is: Maya Jones Jones, Maya
Chapter7: Characters, Strings, And The Stringbuilder
Section: Chapter Questions
Problem 12RQ
Related questions
Question
![CHALLENGE
Feedback?
ACTIVITY
2.15.1: Reading and outputting strings.
Write a program that reads a person's first and last names separated by a space, assuming the first and last names are both single
words. Then the program outputs last name, first name. End with newline.
Example output if the input is: Maya Jones
Jones, Maya
345154.2174782.qx3zay7
1 #include <iostream>
2 #include <string>
3 using namespace std3;
4
5 int main) {
string firstName;
string lastName;
6.
9.
10
11
return 0;
12 }
MacBook Pro](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Fe121d13b-7c25-4145-b798-2e8ea2b242c5%2Fb6a4dbcd-af9f-47de-b28c-8582e13ffe06%2Fviub1ju_processed.jpeg&w=3840&q=75)
Transcribed Image Text:CHALLENGE
Feedback?
ACTIVITY
2.15.1: Reading and outputting strings.
Write a program that reads a person's first and last names separated by a space, assuming the first and last names are both single
words. Then the program outputs last name, first name. End with newline.
Example output if the input is: Maya Jones
Jones, Maya
345154.2174782.qx3zay7
1 #include <iostream>
2 #include <string>
3 using namespace std3;
4
5 int main) {
string firstName;
string lastName;
6.
9.
10
11
return 0;
12 }
MacBook Pro
Expert Solution
![](/static/compass_v2/shared-icons/check-mark.png)
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 2 steps
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
Recommended textbooks for you
![EBK JAVA PROGRAMMING](https://www.bartleby.com/isbn_cover_images/9781337671385/9781337671385_smallCoverImage.jpg)
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
![EBK JAVA PROGRAMMING](https://www.bartleby.com/isbn_cover_images/9781337671385/9781337671385_smallCoverImage.jpg)
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT