Question

Hi I have to write this in C and wasn't sure how! These are two separate...

Hi I have to write this in C and wasn't sure how! These are two separate codes to be done separately.

Write a program that accepts data from the user in the form mm/dd/yyyy and then displays it in the form of yyyymmdd (see below).

Enter a date (mm/dd/yyyy): 2/17/2011

You entered the data 20110217

Write a program that prompts the user to enter a telephone number in the form (xxx) xxx-xxxx and then displays the number in the format xxx.xxx.xxxx (see below).

Enter a phone number [(xxx) xxx-xxxx]: (404) 817-6200

You entered the data 404.817.6200

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

`Hey,

Note: Brother in case of any queries, just comment in box I would be very happy to assist all your queries

1)

#include<stdio.h>
int main()
{
int dd,mm,yyyy;
static char *mon[]= {"January","February","March","April","May","June","July"
"August","September","October","November","December"};
printf("Enter the date(mm/dd/yyyy): ");
scanf("%d/%d/%d",&mm,&dd,&yyyy);
printf("You entered the date %s %d,%d ",mon[mm-1],dd,yyyy);

return 0;
}

b)

#include<stdio.h>

int main()

{

char num[14];

char phone[12];

int i,j;


printf("\n Enter the phone no.[(xxx)xxx-xxxx] :");

scanf("%s",num);

printf("\n%s",num);

i=1;

j=0;

while(num[i]!='\0')

{

if(num[i]==')'||num[i]=='-')

phone[j]='.';

else phone[j]=num[i];

i++;j++;

}phone[j]='\0';

printf("\n%s",phone);


}

​​​​​​​

Kindly revert for any queries

Thanks.

Add a comment
Know the answer?
Add Answer to:
Hi I have to write this in C and wasn't sure how! These are two separate...
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 that accepts a date from the user in the form mm/dd/yyyy

    # C PROGRAMMING LANGUAGEWrite a program that accepts a date from the user in the form mm/dd/yyyy and then dis- plays it in the form month dd, yyyy, where month is the name of the month: Enter a date (mm/dd/yyyy): 2/17/2011 You entered the date February 17, 2011 Store the month names in an array that contains pointers to strings.

  • Write a C program that accepts a phone number of the form +1(xxx)-xxx-xxxx where x is...

    Write a C program that accepts a phone number of the form +1(xxx)-xxx-xxxx where x is a digit, and displays the sum of all digits in the phone number.

  • Write a program that prompts the user to enter the date in mm/dd/yyyy format. The program...

    Write a program that prompts the user to enter the date in mm/dd/yyyy format. The program should use a single input statement to accept the date, storing each piece of the date into an appropriate variable. Demonstrate that the input was obtained correctly by outputting the month, day, and year to the screen. Sample output: Enter (date (mm/dd/yyyy): 02/08/2011 Month entered: 2 Day entered: 8 Year entered: 2011 Challenge: Although the user entered 02, C++ drops the 0 as insignificant...

  • Write a program called telephone.java that prompts the user to enter their phone number using the...

    Write a program called telephone.java that prompts the user to enter their phone number using the specific format: (xxx) xxx-xxxx. The program should check whether the input entered is valid. The program must also check for the parenthesis () for the area code (the first three numbers). Example: (702)892-0516 would be correct but 702-892-0516 would not be correct. Example: Enter your phone number: 702-908-1333. 702-908-1333 is a NOT a valid phone number as there are no parenthesis (). Another example:...

  • Please help this out with all Purpose: Learn how to get input and print out formatted...

    Please help this out with all Purpose: Learn how to get input and print out formatted results using scanf and printf separately in C. 1) Write a C program getPhone Number:c that accepts a phone number from the user in the form XXX-XXX-XXXX, and then displays it in the form (XXX)XXX-XXXX: Enter a phone (XXX-XXX-XXXX): 011-123-4567 You entered (011) 123-4567 Question: Execute your getPhoneNumber.c and attach a screenshot of the output. Then write the source code of getPhoneNumber.c in your...

  • IN PYTHON, Write a program that reads a string from the user containing a date in...

    IN PYTHON, Write a program that reads a string from the user containing a date in the form mm/dd/ yyyy. It should print the date in the form April 12, 2017. Hint: Get the "mm" from the user entered date "mm/dd/yyyy", then convert the "mm" into a month number. You may use an list month_list = ['January', 'February','March','April', 'May','June', 'July','August', 'September', 'October', 'November', 'December']. Use the month number you got from "mm" to get the month name.

  • Write a C++ program that determines the user's age after the   user enters both the current...

    Write a C++ program that determines the user's age after the   user enters both the current date and hisher birthdate as 3   integers:                yyyy mm dd                                                                                             Define a class which is named DateType and will be used to     declare 2 objects: "birthday" and "today". The class will have a function "output" which will display the date in conventional form (like it is above next to Date Assigned: Month dd, yyyy and it will have a second function named     “input”...

  • Q1. Write program calculate the final price of a purchased item using values entered by the...

    Q1. Write program calculate the final price of a purchased item using values entered by the user Hint: you are required to use formatting output for number, currency and percentage. --------------------[Print Receipt] ------------ Enter the quantity: 6 Enter the unit price: $1.98 Subtotals: $10.14 Tax: $ 0.61 at 6% Total: $10.75 ------------------------------------------------ Q2. Write a program that prompts for and reads the users’ first name and last name, Job title, DOB (date of Birth), and the Email address (separately). Then...

  • C Programming Quesition (Structs in C): Write a C program that prompts the user for a...

    C Programming Quesition (Structs in C): Write a C program that prompts the user for a date (mm/dd/yyyy). The program should then take that date and use the formula on page 190 (see problem 2 in the textbook) to convert the date entered into a very large number representing a particular date. Here is the formula from Problem 2 in the textbook: A formula can be used to calculate the number of days between two dates. This is affected by...

  • Write a C++ program that determines the user's age after the user enters both the current...

    Write a C++ program that determines the user's age after the user enters both the current date and hisher birthdate as 3 integers: yyyy mm dd Define a class which is named DateType and will be used to declare 2 objects: "birthday" and "today". The class will have a function "output" which will display the date in conventional form (like it is above next to Date Assigned: Month dd, yyyy EXAMPLE: If the user entered the #’s: 2018 2 6...

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