1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Dmitry [639]
3 years ago
10

c++ 2.30 LAB: Phone number breakdown Given a long long integer representing a 10-digit phone number, output the area code, prefi

x, and line number, separated by hyphens. Ex: If the input is: 8005551212 the output is: 800-555-1212 Hint: Use % to get the desired rightmost digits. Ex: The rightmost 2 digits of 572 is gotten by 572 % 100, which is 72. Hint: Use / to shift right by the desired amount. Ex: Shifting 572 right by 2 digits is done by 572 / 100, which yields 5. (Recall integer division discards the fraction). For simplicity, assume any part starts with a non-zero digit. So 999-011-9999 is not allowed. LAB
Computers and Technology
1 answer:
Nady [450]3 years ago
5 0

Answer:

#include <iostream>

using namespace std;

int main()

{

   //declare variable to store phone numbers,its area code, prefix and line number.

   long phone_number;

   int area_code, prefix,line_number;

   cout<<"Enter 10-digit phone number:"<<endl;

   //input 10-digit phone number

   cin>>phone_number;

   //logic to find area_code, prefix, and line_number.

   area_code = phone_number/10000000;

   prefix = (phone_number/10000)%1000;

   line_number = phone_number%10000;

   //output phone number in asked format.

   cout<<area_code<<"-"<<prefix<<"-"<<line_number<<endl;

   return 0;

}

Output:

Enter 10-digit phone number:

8005551212

800-555-1212

Explanation:

In the above program 10 digit phone number entered by user will be stored in the variable phone_number.

Then using this phone_number variable area_code, prefix, and line number are calculated using the following logic:

area_code = phone_number/10000000;

prefix = (phone_number/10000)%1000;

line_number = phone_number%10000;

Finally these area_code, prefix, and line_number are displayed with hyphen in between using cout statement.

You might be interested in
The information security organization performs a significant role in the implementation of solutions that mitigate risk and cont
sergiy2304 [10]

Answer:

Subject matter experts

Explanation:

Because the security organization institutes the procedures and policies to be executed, they occupy the role of Subject matter expert.

A subject matter expert is a person with a thorough and deep knowledge of a particular process, function, technology, machine, material or type of equipment. Such a person is an expert on that subject.

Therefore the information security organization occupies the role of Subject matter expert.

6 0
3 years ago
The stub: transmits the message to the server where the server side stub receives the message and invokes procedure on the serve
elena55 [62]

Answer:

It does all of these

Explanation:

The stub is able to do all of what we have in this question. It can locate computer connections, locate ports on a computer, transit message to server etc.

in distributed computing, a stub is a piece of code that does the work of converting parameters that are passed between the client and the server at a time of remote procedure call.

The main objective of an RPC is to allow the client to call procedures remotely on another server.

3 0
3 years ago
Can you list one property of each of the following?<br> Excel<br> Word<br> Powerpoint
Rudiy27
Exel is used for graphing, Word for any type of essay or paper, and Powerpoint for presentations.
Hope this helps!
4 0
3 years ago
Read 2 more answers
Advantages and disadvantages of internet
Papessa [141]
Advantages of Internet:
1. Easy and fast access to information2. Up to date news information3. Communications made over internet connecting people around the world4. Convenience in doing like research where you can now do it at home instead of visiting libraries.
Disadvantages of Internet:
1. Possible theft of personal information2. Internet addiction which leads to social isolation3. Inappropriate Contents 
7 0
3 years ago
Read 2 more answers
Preliminaries
Ratling [72]

Answer:

okahsb

Explanation:

8 0
3 years ago
Other questions:
  • Software license infringement is also often called software __________.
    11·2 answers
  • Troubleshooting comes before diagnosing. Answer: false
    7·1 answer
  • Briefly describe the client/server model.
    8·1 answer
  • The following slide was created as part of a presentation that trains new employees how to use the scheduling and calendar softw
    14·2 answers
  • The relational database is the primary method for organizing and maintaining data today in information systems. It organizes dat
    9·1 answer
  • The most widely used presentation software program is Microsoft PowerPoint. You can produce a professional and memorable present
    8·1 answer
  • If all the data in a database is not physically located in one place, it would be a(n _______ database.
    5·1 answer
  • Which picture should i put as my profile picture.
    15·2 answers
  • What is the difference between EPROM and EEPROM, explain why​
    11·1 answer
  • How many levels of heading tags are allowed in html?
    13·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!