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
tiny-mole [99]
3 years ago
12

Part 1: 1) Write a C program getPhoneNumber.c that accepts a phone number from the user in the form XXX-XXX-XXXX, and then displ

ays it in the form (XXX)XXX-XXXX: Enter a date (XXX-XXX-XXXX): 011-123-4567 You entered (011)123-4567
Computers and Technology
1 answer:
Allushta [10]3 years ago
8 0

Answer:

Following are the program, which can be below:

#include <stdio.h> //defining header file

#include <string.h>//defining header file

int main() //defining main method

{  

int x=0,y=0,l=0; //defining integer variable

char phone_number[32] = {'\0'}; //defining char array

printf("Enter a date(xxx-xxx-xxxx): \n "); //print message

printf("Example: 000-000-0000 \n :"); //print message

scanf("%s",phone_number); // taking input from user

printf("%s\n",phone_number); //print number

for(x=0; phone_number[x]; x++) // check character by character

{

if(x==0) // put ( on first character

{

l = strlen(phone_number); //calculate length  

phone_number[l] = '\0'; //check number  

for(y=l; y>=1; y--) //loop to calculate a value

{

phone_number[y] = phone_number[y-1]; //holding value in array

}

phone_number[y] = '('; //assigning bracket

}

if(phone_number[x] == '-') // put ) at first -

{

phone_number[x] = ')'; //assigning bracket

break;

}

}

printf("You entered %s\n",phone_number); //print all value with brackets

}

Output:

Enter a date(xxx-xxx-xxxx):  

Example: 000-000-0000  

:011-123-4567

011-123-4567

You entered (011)123-4567

Explanation:

The description of the above program can be defined as follows:

  • In the above program three integer variable "x, y, and l" and a character array "phone_number" is declared.
  • In the char, variable user input the value and print its value by using the print function.
  • In the next line, a for loop is declare, that checks user input value character by character and counts its length by using the strlen() method, inside the loop a conditional statement is used.
  • In the condition statement check, the values are not equal to null and provide brackets in the inserted value.
You might be interested in
Community gardens are public gardens where local residents can grow plants in a plot. They are very popular, so there are often
Black_prince [1.1K]

Answer:

The information obtained is

  • Figure out who has been waiting the longest
  • Make a map of the waitlisted people

Explanation:

The information obtained from the combine data set is as follows

  • Figure out who has been waiting the longest
  • Make a map of the waitlisted people

The information from the waitlist database is combined thus the overall wait time of  the participants is estimated. Also the map of people around the globe is also made possible on the basis of the second database.

4 0
4 years ago
NO THIS ISNT ANY HOMEWORK!
IRISSAK [1]

Answer:

you can run minecraft on virtually anything with the lowest settings and optifine, as long as you dont use shaders or beefy texture packs

Explanation:

4 0
3 years ago
Read 2 more answers
When doing a complex presentation, which of the following would be the best tool to begin designing your presentation?
Dafna1 [17]
An outline can be a best tool to begin describes a presentation....
4 0
4 years ago
Read 2 more answers
Lisa has a section of her document that she would like to include in the index. Which option should Lisa choose?
kupik [55]

Answer:

For including a part of the text within the index, you need to make use of the Mark Entry option. And here you can fill the required information for curating your index, you need to just follow the instruction as required, and you will be fine.

Explanation:

Please check the answer.

8 0
3 years ago
Why do people yeet yeet and ree
DiKsa [7]

Answer:

Cause they are trying to be annoying

Explanation:

Something is wrong with them :)

8 0
3 years ago
Read 2 more answers
Other questions:
  • When is a wrecker considered to be an emergency vehicle?
    12·1 answer
  • Can you please help me at question two
    13·1 answer
  • A chef writing up her famed recipe for beef stew realizes she has switched parsley and oregano everywhere in the recipe. The che
    13·1 answer
  • Instructions:Select the correct answer.
    9·1 answer
  • You can easily view the ruler on a document by selecting the Show Ruler button located _____.
    11·2 answers
  • Which search engine do you prefer? Why
    15·2 answers
  • You are troubleshooting a mobile device with no sound output from the headset or external speakers.
    6·1 answer
  • Last bittttt of points
    8·1 answer
  • Which shortcut keys can be used to duplicate a slide?
    15·1 answer
  • ________ is a group meeting-based process for requirements collection. a. Reverse engineering b. Joint application design c. Hum
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!