Mega Code Archive

 
Categories / C++ / Data Type
 

Print a name in two different formats

#include <iostream> #include <string> using namespace std; const string FIRST = "First";     const string LAST = "Last";       const char MIDDLE =   'M';         int main() {     string firstLast;        string lastFirst;        firstLast = FIRST + " " + LAST;     cout << "Name in first-last format is " << firstLast << endl;     lastFirst = LAST + ", " + FIRST + ", ";     cout << "Name in last-first-initial format is ";     cout << lastFirst << MIDDLE << '.' << endl;     return 0; }