previous | start | next

Example 6



    1   // File: name2.cpp
    2   // Description: Changes order of first and last names. Names are input 
    3   //              by the user from the keyboard.
    4   // Author: 
    5   // Created: 07 Sep 05
    6   
    7   #include <iostream>
    8   #include <string>
    9   
   10   using namespace std;
   11   
   12   int main()
   13   {
   14     string fname;
   15     string lname;
   16   
   17     cout << "This program prints out your name"
   18       << " in a little box.";
   19     cout << "\nFirst name: ";
   20     cin >> fname;
   21     cout << "\nLast name: ";
   22     cin >> lname;
   23   
   24     cout << "\nFirst name has length " << fname.length() << endl;;
   25     cout << "Last name has length " << lname.length() << endl << endl;
   26   
   27   
   28     cout << "\t********************" << endl;
   29     cout << "\t* " << lname << ", " << fname << " *" << endl;
   30     cout << "\t********************" << endl;
   31   
   32   
   33     return 0;
   34   }


previous | start | next