#include<iostream.h>
#include<stdlib.h>
#include<conio.h>
#include<string.h>
class phone
{
int p,c,s,ph[4],std[3];
public:
void accept();
void display();
void new_ph();
};

void phone::accept()
{
cout<<"Enter STD no.:\t";
cin>>s;
cout<<"\n\nEnter Exchange code : ";
cin>>c;
cout<<"\n\nEnter phone number : ";
cin>>p;
cout<<"\n\nOld Phone Number is   : ";
cout<<s<<"-"<<c<<"-"<<p;

}

void phone::display()
{
for(int i=0;i<=2;i++)
cout<<std[i];
cout<<"-";
cout<<c;
cout<<"-";
for(i=0;i<=2;i++)
cout<<ph[i];
}

void phone::new_ph()
{
int i=2,k=0;
while(s>0)
{
k=s%10;
std[i]=k;
s=s/10;
i--;
}
i=2,k=0;
while(p>0)
{
k=p%10;
ph[i]=k;
p=p/10;
i--;
}
std[2]=std[2]+1;
int tmp;
tmp=ph[0];
ph[0]=ph[1];
ph[1]=tmp;
}


int main()
{
clrscr();
phone p;
p.accept();
p.new_ph();
cout<<"\n\nNew Phone  Number is  : ";
p.display();
getch();
return 0;
}

Post a Comment

Previous Post Next Post