Answer to Question #99409 in C++ for Caleb

Question #99409
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: Maya Jones
Jones, Maya
1
Expert's answer
2019-12-16T05:40:07-0500
#include <iostream>
#include <string>

using namespace std;

int main() {
    // Variables
    string firstName;
    string lastName;

    // Enter the first and last name
    cout << "Write first and last name\n";
    cin >> firstName >> lastName;

    // Output the result
    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