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;
}
#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;
}
Comments
Leave a comment