Question: Write a C program that asks the user to enter a telephone number as a string that contains a three digit area code followed by

Write a C program that asks the user to enter a telephone number as a string that contains a three digit area code followed by a seven digit number. Any other characters will be ignored, and only the first 10 digits will be considered. The string should have at most 50 characters. If the user does not provide at least 10 digits, an error message should be outputted. It should report the telephone number in the format (123) 456-7890.

Examples:

User enters: 9111234567

Program Output: (911) 123-4567

User enters: xyz911-123-4567

Program Output: (911) 123-4567

User enters: 911

Program Output: Please try again, not enough digits

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!