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]
2 years 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]2 years 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
"what windows process is responsible for authenticating users?"
Likurg_2 [28]
Lsass.exe /................................................
8 0
3 years ago
How to make a Tip Calculator in code?
ki77a [65]
You should have the percentage of tip based on the service that you received.
Then you multiply the percentage of tip by the amount of money that you have to pay for what you bought.
4 0
3 years ago
What does the following if statement do?<br><br> if (num1 == Math.abs(num1))
Gennadij [26K]

This statement checks if num1 is equal to the absolute value of num1

For instance,

num1 = 4 and the absolute value of num1 = 4. This would run the code inside the if statement but if num1 = -1 the absolute value of num1 = 1 and the if stamtent would be skipped because -1 does not equal 1

6 0
3 years ago
Assume you have an XML Tree variable called quiz initialized with the following valid XML document. You are not required to draw
blagie [28]

Answer:

See explaination.

Explanation:

question is the root element which have two children one is M-C and other is Coding.

Again M-C have two sub children Points and parts

Note: The tree will be as shown in the attachment. kindly refer to attachment.

Here if we see the child of quiz(questions) at 0 position is number of type M-C and another child at location 1 is number of type Coding.

Now quiz.child(0) is number of type M-C which has two child and child at 0 is Points and child at 1 is Parts

quiz.child(0).child(1) is Points and now further points doesn't have any children hence going further to quiz.child(0).child(1).child(0) is nothing hence it will not return anything.

Next quiz.child(1) is number of type coding and value is 5.

Size of the tree is (2^depth)-1

and here depth of tree is 3 hence size is (2^3)-1 i.e. 7

8 0
3 years ago
The ____ property configures a shadow effect on the text displayed within an element
Bogdan [553]
Shareder Is the answer I put. 
3 0
3 years ago
Other questions:
  • Two powerboats are about to cross paths. what should the boat on the starboard (right) do?
    11·1 answer
  • Can anyone find any words in here?
    14·2 answers
  • Making the data impossible to recover even by applying physical forensics methods is known as __________ of media.
    13·1 answer
  • Choose the answer. Janice's IT department found that her computer had a program on it that was collecting her personal informati
    5·1 answer
  • Please help if you answer correcly i will give you brainelst!!!!!!!!!!!!!!!!!!
    6·2 answers
  • Match each with the correct answer.
    7·1 answer
  • Match each method of communication with its intended purpose.
    14·1 answer
  • WHICH PROGRAMMING LANGUAGES ARE THE BEST FOR PROGRAMMING?
    14·1 answer
  • What do you understand by cloud computing? list the advantages of clould computing.​
    13·2 answers
  • What are some innovations that television has undergone since its original invention ?
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!