LAB: Phone number breakdown Given a long long integer representing a 10-digit phone number, output the area code, prefix, and line 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;

Respuesta :

The program illustrates the use of modulo operator.

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

Take for instance:

The result of 4 % 3 is 1, because when 4 is divided by 3, the remainder is 1

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:

https://brainly.com/question/13219435

Ver imagen MrRoyal