Answer:
Following are the program is given below
#include <iostream> // header file
#include<string> // header file
using namespace std; // namespace
int main() // main function
{
string fname,lname; // variable declaration
cin>>fname>>lname; // Read the input by user
cout<<lname; // print last name
cout<<", "; // display comma
cout<<fname<<endl; // display first name
return 0;
}
Output:
Maya Jones
Jones, Maya
Step-by-step explanation:
Following are the description of program .
- Declared a variable "fname" and the "lname" as the string datatype .
- Read the input by user in the "fname" and the "lname" variable by using cin function in c++.
- After that print the "lname" variable.
- then print the comma and finally print the "fname" variable