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
When assigned to a cell, the __________ function returns a number that corresponds to the system date and time beginning with De
Sloan [31]

Answer:

Option D: NOW

Explanation:

In Microsoft Excel, NOW function can be used to return a serial number that  corresponds to the system date and time beginning with December 31, 1899.

The NOW function is useful when a date and time is required for calculation or display. The value will be updated each time we open the Excel worksheet.  To use the NOW function, we can type in the formula as follows:

<em>=NOW() </em>

7 0
3 years ago
If you want to present slides to fellow students or co-workers, which productivity software should you use to create them?
slamgirl [31]
Microsoft powerpoint? i think thats what this is asking
4 0
3 years ago
Read 2 more answers
Consider the unsigned decimal number 35. What is the value in hexadecimal?<br><br> 3510 = _______ 16
Lena [83]

Answer:

(35_{10}) = (23)_{16}

Explanation:

The Hexa-decimal numbers have base 16 and includes numbers:

0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E and F

The given steps are performed to convert a decimal number to hexa-decimal number, here to convert decimal number 35 to hexa-decimal number:

  • Divide 35 by 16
  • Note the remainder, r which is 3 here and quotient which is 2
  • Again divide 2 (quotient) by 16 and note the remainder, r' which is 2 and quotient is 0
  • We will stop here as the quotient is now 0. Usually division by 16 is repeated until we get quotient = 0
  • Now arrange the remainder in reverse order to get the hexa-decimal number as r'r
  • The hexa-decimal number is (23)_{16}
4 0
2 years ago
_______is a term which describes how the operating system will interrupt the execution of an application when an application of
a_sh-v [17]

Answer:

scheduling

Explanation:

Scheduling- it is referred to as assigning a task to complete the goal or work on time. he works can include data flow, processing of data, etc.

There are two main types of scheduling

1) Preemptive process

2) Non- preemptive process

Preemptive process -  in this process, priority is given to important tasks rather than less important tasks. the current task can be held for an important task

Non-preemptive process -  It is referred to that process when the predefined schedule follows. In this  process, next task executed only when current task finish

6 0
2 years ago
+
quester [9]

Answer:

Network administrator

5 0
3 years ago
Read 2 more answers
Other questions:
  • When purchasing a(n) ________ computer, having cellular as well as wifi can be important?
    9·1 answer
  • Maria found a cupcake recipe on a cooking blog. However, she would like to read comments and suggestions before she begins bakin
    6·2 answers
  • _____ is used to temporarily hold small units of program instructions and data immediately before, during, and after execution b
    10·1 answer
  • Jim wants to buy a car, but he’ll probably only need it for a couple of years. He has a short commute to work, so he won’t be pu
    10·1 answer
  • Develop a Python program. Define a class in Python and use it to create an object and display its components. Define a Student c
    11·1 answer
  • How do you compare text on different pages of a document?
    14·1 answer
  • Adrian wants to run a digital movie clip that his friend shared with him through email. His system has 2 GB of RAM and 20 GB of
    15·1 answer
  • The rules of right-of-way<br> Pedestrians, bicyclists, and skateboarders<br> when they use the road.
    12·1 answer
  • Is media good for the brain?
    7·2 answers
  • 1.Microsoft Word is a/an ........​
    8·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!