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
Suppose that the domestic production of computer games creates enjoyment for those who play the games. Domestic production of co
kirill [66]

Answer:

a

Explanation:

Based on the information provided within the question it can be said that the best possible policy to encourage this would be to impose tariffs on computer game imports. This would force company's to begin domestic production of computer games in order to continue making the profits from the domestic market as opposed to losing out on all of the opportunities that the domestic market offers them.

6 0
3 years ago
What is the effects of computer and internet attacks​
ZanzabumX [31]

Answer:

ads, damage, or bugs

Explanation:

7 0
3 years ago
Read 2 more answers
Which of the following is NOT a possible combination of values of the variables in this program when it finishes running?
Nady [450]

Answer:

Definitely D

Explanation:

When you flip a coin it’s a 50/50 chance. Meaning it’s equal.

7 0
3 years ago
Read 2 more answers
A computer equipped with fingerprint recognition software, which denies access to a computer to anyone whose fingerprint is not
morpeh [17]

Answer: C. It is not possible for any top computer hacker to gain access to a computer equipped with the recognition software solely by virtue of skill in replicating the structure of fingerprints

Explanation:

Option A is incorrect. There's no information on the speed and analysis of the fingerprint.

Option B is incorrect. No information regarding computer installation was given in the passage.

Option C is correct. With the information, it can be concluded that it is impossible for a top hacker to have access to the protected computer.

Option D is Incorrect. Information regarding time and investment costs that were incurred during the software development wasn't given in the passage

Option E is Incorrect. The passage didn't give information on the errors that the software produced.

8 0
3 years ago
The purpose of the trusted platform module is:
Elza [17]
A Trusted Platform Module is a specialized chip on an endpoint device that stores RSA encryption keys specific to the host system for hardware authentication. Each TPM chip contains an RSA key pair called the Endorsement Key. The pair is maintained inside the chip and cannot be accessed by software.
6 0
3 years ago
Read 2 more answers
Other questions:
  • Is this statement true or false?
    12·2 answers
  • Where is line-of-sight Internet common?<br> In space<br> Outdoors<br> Inside<br> In businesses
    10·1 answer
  • What was one complication caused by the tsunami that struck japan in 2011?
    15·1 answer
  • Write a function named "higher_lower" that takes an int as a parameter and returns "higher" if 14 is greater than the input and
    11·1 answer
  • Please create C program, the task is to implement a function edoublepowerx that has an input parameter x of floating-point value
    11·1 answer
  • java Write a program that reads a list of words. Then, the program outputs those words and their frequencies. The input begins w
    11·1 answer
  • What are the benefits of writing functions that use parameters and return? Try to list at least two.
    12·1 answer
  • How do you use switch board in the office​
    6·1 answer
  • Wight an essay on Knowledge sharing among robots.<br> please and please do not delete my question.
    7·1 answer
  • Do anyone know how to code like I need someone do a code for me?
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!