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
satela [25.4K]
1 year ago
8

LAB: Phone number breakdown Given a long long integer representing a 10-digit phone number, output the area code, prefix, and li

ne number using the format (800) 555- 1212 Ex: If the input is: 8005551212 the output is: (800) 555-1212 Hint: Use the modulo operator (%) 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 0119998888 is not allowed. 34/202.2014 LAB ACTIVITY 2.30.1: LAB: Phone number breakdown 0 / 10 main.c Load default template... 1 #include 2 3 int main(void) 4 5 5 long long phoneNumber; 6 long long prefix; ? long long areaNum, lineNum; scanf("%11d", &phoneNumber); printf("%d11", phoneNumber); 9 10 11 12 + 13 14 15 16 17 18 areaNum = phoneNumber/10000000; prefix = (phoneNumber/10000)%10000; lineNum = phoneNumber % 10000 printf("llf-llf-11f\n", areaNum, prefix, lineNum); return;
Computers and Technology
1 answer:
SSSSS [86.1K]1 year ago
8 0

The program illustrates the use of modulo operator.

The modulo operator (%) returns the remainder of a division.

<u>Take for instance: </u>

<em>The result of 4 % 3 is 1, because when 4 is divided by 3, the remainder is 1</em>

So, the program in C is as follows, where comments are used to explain each line

#include <stdio.h>

int main(){

   //This declares all variables as integer

   long phoneNumber, prefix,areaNum, lineNum;

   //This gets input for phoneNumber

   scanf("%ld", &phoneNumber);

   //This prints the  input for phoneNumber

   printf("%ld", phoneNumber);

   

   //This calculates the area code

   areaNum = phoneNumber/10000000;

   //This calculates the prefix

   prefix = (phoneNumber/10000)%1000;

   //This calculates the line numbers

   lineNum = phoneNumber%10000;

   

#This prints the required area code

   printf("\n(%ld)%ld-%ld\n", areaNum, prefix, lineNum);

   return 0;

   

}

At the end of the program, the phone number breakdown is printed

See attachment for sample run

Read more about C programs at:

brainly.com/question/13219435

You might be interested in
"when a dynamic web page is requested, the web server passes the request to"
nalin [4]
System operations of the website u are  asking to access
7 0
3 years ago
What are the steps involved in accepting all the changes in a document?
Makovka662 [10]

To accept all the changes in a document click Accept All.

4 0
3 years ago
Read 2 more answers
E-mails that are mailed directly to a consumer without their knowledge or permission are called
gizmo_the_mogwai [7]
E-mails that are mailed directly to a consumer without knowledge or permission are called spam
6 0
2 years ago
Read 2 more answers
Workspace Remember for a moment a recent trip you have made to the grocery store to pick up a few items. What pieces of data did
PtichkaEL [24]

Answer:

ATM card and the pin number, the status of the bank account and the total of the purchase and the account and method of payment.

Explanation:

The POS or point of service is a device that allows the purchase of product from a commercial store to be done wirelessly and cashless.

It promotes The cashless policy to reduce the circulating physical currency. The POS electromagnetic wave to wirelessly access bank database to retrieve bank account information.

It takes in the smart card, and with the command, retrieves the bank account information addressed on the card. The cashier types the total price of purchased product and it is automatically minus and updated on the account database. Then the invoice of the transaction is issued to the customer.

8 0
3 years ago
Consider the following JavaScript program:
dem82 [27]

Answer:

Variable       Where Declared

In Sub1 :

        A        Sub1

        Y        Sub1

        Z        Sub1

        X        Main

In Sub2:

        A        Sub2

        B        Sub2

        Z        Sub2

        Y        Sub1

        X        Main

In Sub3 :

        A        Sub3

        X        Sub3

        W       Sub3

        Y        Main

        Z        Main

Explanation:

In static-scoped languages with nested subprograms, the declaration of a variable is checked with the subprogram, if it is not found, it check within the parent method that called it, it continue until it find a declaration, if no declaration is found, it display an error.

In Sub1, a, y, z is declared there while the declaration of x is found in main.

In Sub2, a, b, z is declared, declaration of y is found in sub1 and declaration of x is found in main.

In Sub3, a, x, w is declared while the declaration of y, z is from the main.

7 0
3 years ago
Other questions:
  • Consider a physical transmission medium of capacity C bits/sec between two stations that have I bits of information sent/receive
    6·1 answer
  • Which type of network is created when you use encrypted tunnels between a computer or a remote network and a private network thr
    13·1 answer
  • Why is important to build strong connections
    9·2 answers
  • An advertisement for new headphones lists the cool colors available, the great sound quality, and the fabulous reviews but fails
    14·1 answer
  • What type of network is capable of delivering voice, video streams, text, and graphics between many different types of devices o
    15·1 answer
  • Video Fundamentals
    6·1 answer
  • A set of well-defined steps for performing a task or solving a problem is known as a(n):A) HierarchyB) AlgorithmC) Central Proce
    15·1 answer
  • Copy the countdown function from Section 5.8 of your textbook. def countdown(n): if n &lt;= 0: print('Blastoff!') else: print(n)
    8·1 answer
  • As a general rule, what is the size of a brochure?
    11·1 answer
  • Explain why the process of sketching in engineering might resemble a loop or a cycle.
    15·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!