Wednesday, 26 October 2011

A simple program in C++ to concatenate a phone-number


The following program can be implemented to concatenate a phone number if you know its area, exchange and phone number.


#include<iostream.h>
#include<conio.h>
#include<stdio.h>

struct phone
{
int area_code;
int exchange;
int phone_number;
};


void main()
{
phone a,e,p;
clrscr();
cout<<"Enter the Area Code:";
cin>>a.area_code;
cout<<"\n\n";
cout<<"Enter the exchange:";
cin>>e.exchange;
cout<<"\n\n";

cout<<"Enter the number:";
cin>>p.phone_number;
cout<<"\n\n\n\n";
cout<<"My phone number is:";
cout<<"\n\n";
cout<<"\t\t\t"<<"+"<<"("<<a.area_code<<")"<<e.exchange<<"_"<<p.phone_number;
getch();
}

0 comments:

Post a Comment