Sunday, 29 April 2012

Working with Strings in C++

#include <iostream.h>
#include <stdio.h>
using namespace std;

int main()
{
   string a[3];                                
   string e;                                        
   for (int i = 0; i <=3; i= i + 1)              
     {
     cout << "Type the name of someone you hate\n";
     cin >> e;
     a[i] = e;
     }                                                 
   for (int i = 0; i <=3; i = i + 1)                    
     {                                                 
     cout << a[i] << " sounds like the name of a moron.\n";                      
     }                                                
   cout << "\nPress ENTER to continue..." << endl;
   getchar();
   return 0;
}


No comments:

Post a Comment