Simple Telephone Directory using C++


#include<iostream>
#include<string>

using namespace std;

main()
{
      string add[5][2] = { {"128","RM500"}, {"204","RM750"}, {"601","RM495"}, {"609","RM800"}, {"612","RM940"} } ;
      string addnum;
      
      for(int i=0; i<5; i++)
      {
              for(int j=0; j<2; j++)
              {
                     cout<<add[i][j]<<"-" ; 
              }
              cout<<endl;
      }  
      
      start:
            
      cout<<"Enter a address number: ";
      //getline(cin, addnum);
      cin>>addnum;
      
      
      int i=0;
      bool isFound = false;
      
      for( i=0; i<5; i++)
      {
             if(add[i][0] == addnum)
             {
                          isFound = true;
                          break;
             }
      }
      
      if(isFound == true)
      {
                 cout<<"Rent: "<<add[i][1]<<endl;
                   
      }
      
      goto start;
      
system("pause");
      
}
Advertisements

About praveenaj

I'm just an average guy who enjoys doing Programming/Web Designs/Pencil art & drinking coffee :)
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s