-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy path1.cpp
32 lines (24 loc) · 981 Bytes
/
1.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/*
A phone number, 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 these three parts of a phone number separately. Call the structure
phone . Create two structure variables of type phone . Initialize one, and have the user
input a number for the other one. Then display both numbers.
*/
//author @Nishant
#include<iostream>
using namespace std;
struct phone{
int areacode, exchange, number;
};
int main(){
phone phone1, phone2;
phone1.areacode = 212;
phone1.exchange = 767;
phone1.number = 8900;
cout << "Enter your areacode, exchange, and number: ";
cin >> phone2.areacode >> phone2.exchange >> phone2.number;
cout << "My number is (" << phone1.areacode << ") " << phone1.exchange << "-" << phone1.number << endl;
cout << "Your number is (" << phone2.areacode << ") " << phone2.exchange << "-" << phone2.number << endl;
return 0;
}