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
How much memory did the first smartphone have?
hjlf

Memory 1 MB (2 × HM658512LTT PSRAM)

Storage 1 MB of NOR Flash expanded to 2 MB by Stacker compression + 32KB BIOS NOR Flash

6 0
3 years ago
Mike wants to capture some images of his application as it appears on the screen. In order to do this, Mike needs to know how to
Stells [14]
D is the best answer
I hope it’s work
5 0
3 years ago
Which of the following is not a valid technique to create a function stub?
In-s [12.5K]

An option which isn't a valid technique to create a function stub is to: D. leave the function body empty.

<h3>What is a function stub?</h3>

A function stub can be defined as a type of function that can be called safely without an error. However, a function stub has no definition because it doesn't actually perform any action when called.

In this context, leaving the function body empty is an option which isn't a valid technique to create a function stub.

Read more on function stub here: brainly.com/question/17214711

#SPJ1

6 0
2 years ago
Everything is made of tiny Antoms each of these Antoms is made up of a core that has a positive charge and some electrons that c
arlik [135]

Answer:

Magnetism

Explanation:

Magnetism or magnetic energy is a natural phenomenon, we can find magnetism in some materials like nickel, cobalt, and iron, or their alloys are magnets, this was produced the first time in Greece at the city Magnesia del Meandro, for this city is the name magnetism, there were stones that attracted and this was called natural magnetism.

4 0
3 years ago
What does HTML and CSS stand for in coding?
lisov135 [29]
HTML stands for hypertext markup language.
CSS stands for cascading styling sheet.
8 0
3 years ago
Other questions:
  • Which computer device works like the human central nervous system by connecting all the computer’s parts together and allowing t
    9·1 answer
  • I microwaved my phone and this Bluetooth popup won't go away and I can't connect to Bluetooth. Help. I have a Google pixel 3XL I
    6·1 answer
  • What does the word tolerance mean in textiles?
    9·1 answer
  • The technique of ________ uses three columns that allows the entrepreneur to weigh both the advantages and the disadvantages of
    13·1 answer
  • Items that are cut or copied are placed on the Clipboard.
    6·2 answers
  • Write a program to enter a number and test if it is greater than 45.6. If the number entered is greater than 45.6, the program n
    10·1 answer
  • Is ryzen really better for all-around purpose, and intel is better for gaming?
    7·1 answer
  • You have installed Windows Server 2016 on a new server and want to centralize user logons and security policies. What type of so
    13·1 answer
  • If wearing protective gloves, there's no need to wash your hands after exposure to blood.
    14·1 answer
  • The procedure by which a process's state is saved before being swapped out of the cpu, then us restored to the state when the pr
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!