Question

Please write a program to find the area code, exchange code, and the user number from...

Please write a program to find the area code, exchange code, and the user number from any phone number (i.e., 10 digits) entered by the user. [hints: assume the common phone number format (3 digits area code)-(3 digits exchange code)-(4 digits user number)] in C language.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

SNAPSHOT OF CODE:

CODE :

#include<stdio.h>
int main()
{
// Variable Declaration
int i,areaCode,exchangeCode,userNumber;
long long int phoneNumber;

// Entering User Input
printf("Enter The Phone Number\n");
scanf("%lld",&phoneNumber);

// Calculating Codes
userNumber = phoneNumber%10000;
areaCode = phoneNumber/10000000;
exchangeCode =( phoneNumber/10000 ) % 1000;

// Displaying Codes
printf("Area Code is : %d \n",areaCode);
printf("Exchange Code is : %d \n",exchangeCode);
printf("User Number is : %d \n",userNumber);
return 0;
}

OUTPUT:

// Feel Free To Ask Any Question !!!

// Keep Then Happy Chegging !!!

// Thank You !!!

Add a comment
Know the answer?
Add Answer to:
Please write a program to find the area code, exchange code, and the user number from...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a program **(IN C)** that displays all the phone numbers in a file that match the area code...

    Write a program **(IN C)** that displays all the phone numbers in a file that match the area code that the user is searching for. The program prompts the user to enter the phone number and the name of a file. The program writes the matching phone numbers to the output file. For example, Enter the file name: phone_numbers.txt Enter the area code: 813 Output: encoded words are written to file: 813_phone_numbers.txt The program reads the content of the file...

  • build a phone number from digits entered by your user. Your program will loop until 10...

    build a phone number from digits entered by your user. Your program will loop until 10 valid digits have been entered. It will then use those digits to display the phone number entered using the format: XXXXXXXXXX (or (XXX) XXX – XXXX for extra credit). The program will ask for a digit, it will check to see if the digit is actually between 0 and 9 inclusively. If so, the digit will be stored as the next number in the...

  • How to write this code in C++???? using fstream Write a program which: Asks the user...

    How to write this code in C++???? using fstream Write a program which: Asks the user to enter a positive integer greater than 0 Validates that the entry is a positive integer Outputs the digits in reverse order with a space separating the digits Outputs the even digits not in reverse order with a space separating the digits (consider zero to be even) If there are no even digits, the an appropriate message should be displayed: There are no even...

  • Please write a java program that takes a large, user-entered number (usually 10 digits) and tallies...

    Please write a java program that takes a large, user-entered number (usually 10 digits) and tallies the 10 digits to be used in an array. Then, the method should tell the user how many of each number was input. For example, for the number 445903218, the program should say "2 4's, 1 5...," etc etc.

  • Create a design document for a program that will take a number from the user and...

    Create a design document for a program that will take a number from the user and convert it to IEEE single precision format. The program displays the IEEE representation (Single precision) of the number entered by the user. PLEASE ADD THE PSEUDOCODE AND CODE WITH C PROGRAMMING

  • 10. AU.S. phone number consists of three sections: (1) Area code (null or three digits); (2)...

    10. AU.S. phone number consists of three sections: (1) Area code (null or three digits); (2) prefix code (three digits); and (3) postfix code (four digits). Area code - it can be null or consists of three digits Prefix code - it consists of three digits with non-ZERO or non-ONE as the first digit in the Prefix code section, i.e. 334-123-4567 is invalid because the first digit in the Prefix code is ONE. Postfix code - it consists of four...

  • This is Python The program should accept input from the user as either 7-digit phone number...

    This is Python The program should accept input from the user as either 7-digit phone number or 10-digit. If the user enters 7 characters, the program should automatically add "512" to the beginning of the phone number as the default area code. Dash (hyphen) characters do not count in input character count, but must not be random. If the user enters dashes the total character count must not exceed 12. The program should not crash if the user enters invalid...

  • Program#3(17 points): write a java program (SunDigits) as follows The main method prompts the user to enter an integer number. The method then calls Method Sum (defined blew) to add the digits and re...

    Program#3(17 points): write a java program (SunDigits) as follows The main method prompts the user to enter an integer number. The method then calls Method Sum (defined blew) to add the digits and return their total. The main method then prints the digits total with proper label as shown below Method Sum )is of type integer and takes an integer value. The method recursively adds up the digits and returns their total. Document your code and use proper prompts for...

  • java Write an application that input a number from the user and checks if all digits...

    java Write an application that input a number from the user and checks if all digits are prime numbers using method prime. The number entered can be of any size. If all digits are prime your program should stop. Use do/while for reading the input and any loop format to test if the number is prime. When checking the prime numbers don’t use an if to check numbers from 1 – 9; you need to find an algorithm to check...

  • Write a python program that does the following. a. It asks the user to enter a...

    Write a python program that does the following. a. It asks the user to enter a 5-digit integer value, n. b. The program reads a value entered by the user. If the value is not in the right range, the program should terminate. c. The program calculates and stores the 5 individual digits of n. d. The program outputs a “bar code” made of 5 lines of stars that represent the digits of the number n. For example, the following...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT