46.9k views
1 vote
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.

User HighAley
by
7.9k points

1 Answer

0 votes

Final answer:

To store parts of a phone number separately, a structure named 'phone' can be used in a program. It contains three integer fields: areaCode, exchange, and number, allowing the phone number to be divided into manageable chunks.

Step-by-step explanation:

A phone number can be divided into three parts: the area code, the exchange, and the number. To store these parts separately in a computer program, you can use a structure called phone. Here is an example code snippet in C programming language that demonstrates how to create such a structure:

struct phone {
int areaCode;
int exchange;
int number;
};

This phone structure has three integer fields that correspond to the three parts of a phone number. You can use this structure to create phone number variables in your program and access each part of the phone number individually.

User Alexander Wallin
by
8.3k points

Related questions

1 answer
4 votes
231k views
2 answers
4 votes
40.0k views