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 parameter passing mechanisn used in C is
Step2247 [10]

Answer:

Hope you understand this answer

7 0
3 years ago
Read 2 more answers
What can a user modify on a business card using the Edit Business Card dialog box? Check all that apply.
vredina [299]

Answer:

layout,image,font,background color,

Explanation: i just did it on edge

7 0
3 years ago
Suppose that sum is an int variable. The statement sum += 7; is equivalent to the statement sum = sum + 7;
ivanzaharov [21]
That's correct.

Same goes for -=  *=  and  /=

It essentially just means "Do this, to this variable".


sum += 7  "Add 7 to sum"
result *= 10  "Multiply result by 10"
So on, and so forth.
4 0
3 years ago
Create a jQuery ready listener that updates the options within the element with ID toCurrency such that: The first element is: S
nlexa [21]

Answer:

Enter USD and select desired currency.

US Dollars (USD): 100.00

Select Currency: Canadian Dollar (CAN)

Canadian Dollar (CAN): 130.00

Explanation:

See full code attached.

5 0
3 years ago
Jeremy Bridges is an executive for Green Web Designs, where his primary role is to ensure the security of business systems and d
klasskru [66]

Answer:

Chief Security Officer

Explanation:

According to the given statement in the question the Jeremy's role in the company is "Chief Security Officer (CSO)".

The chief Security officer has the role of developing and looking on to the strategies and policies that are required for maintaining the operational, strategic, financial and reputational security  of the  overall company.

6 0
3 years ago
Other questions:
  • What type of device is built into a tablet computer and can send data over radio waves to another device such as a laser printer
    10·1 answer
  • Generally speaking, mobile sites are good for acquiring new customers and inspiring new relationships while mobile apps are good
    6·1 answer
  • Once your hard drive is installed what needs to be done to the drive and what do these two tasks do
    12·1 answer
  • How is a cell named in microsoft excel 2016
    10·1 answer
  • The clear emergence of a leader and the development of group norms and cohesiveness are the key indicators of the ________ stage
    6·1 answer
  • You are running out of storage space on one of your servers. you need to purchase an external hard drive, as there are no drive
    8·2 answers
  • Suppose you're currently completing an examination online. When you're finished, you click on Reset Exam. Why would you do this?
    8·1 answer
  • Introduction to computing systems: from bits and gates to c and beyond
    7·1 answer
  • What is the first step that you have to perform before you can add a windows package to a wim file?
    9·1 answer
  • Which statement describing the arcade games played in the 1970s is true?
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!