jituTechnology

jituTechnology

>Write a Program that uses a structure to store the three parts of a phone number separately, call the structure phone

>/* A phone no., such as (212) 767-8900 can be thought of as having three parts: the area code (212), the exchange (767), and the number (8900).Write a Program that uses a structure to store the three parts of a phone number separately, call the structure phone. Create two structure variable of type phone. Initialize one, and have the user input a number for the other one.Then display both number. The interchange might look like this: Enter your code, exchange and number: 145 555 1212

Programmed by:
Name: Jitendra Kr Yadav
Roll: 10116 (NCIT-ELX)
Date: 15 July 2011 */
#include <iostream.h>
#include <conio.h>
struct phone
{
intareacode;
int exchange;
int number;
};
int main()
{
phonea,b;
a.areacode= 212;
a.exchange=-767;
a.number=-8900;
cout<<“Enter the area code: “;
cin>>b.areacode;
cout<<“Enter the exchange: “;
cin>>b.exchange;
cout<<“Enter the number: “;
cin>>b.number;
cout<<“My number is :”<<“(“<<a.areacode<<“)”<<a.exchange<<a.number<<endl<<“Your number is: “<<“(“<<b.areacode<<“)”<<b.exchange<<“-“<<b.number;
getch();
return(0);
}
Output Sample:
Enter the area code: 145
Enter the exchange: 555
Enter the number: 1212
My number is: (212)-767-8900
Your number is : (145) 555-1212

No comments yet.

Add a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.



Connect with Me

GPO 8973 NPC 541; Kathmandu Nepal
Phone: +977 9851236800

Calendar

April 2024
S M T W T F S
 123456
78910111213
14151617181920
21222324252627
282930