Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Date Conversion (C program) Write a program that accepts a date in International

ID: 3774482 • Letter: D

Question

Date Conversion (C program) Write a program that accepts a date in International Date Format (yyyy mm dd) from the command line and converts it to an American Date Fromat, where the name of the month is displayed. If three arguments are not entered into the program, or the arguments are not numbers, an error message should be displayed. (must contain) Specifications: Store the month names in an array that contains pointers to strings. Use argc and argv as inputs to the main program. argv can be declared as a character pointer array or a character pointer to a pointer (via Netbeans). Use of the atoi() function (Ascii TO Integer) will be extremely useful.

output:

Please enter an ISO Date into the program (yyyy mm dd)

Input: 201x 33 s *if not in correct yyyy mm dd prompt to reenter

Output:

Please enter an ISO Date into the program (yyyy mm dd)

Input: 2011 11 24

Output: Date: November 24, 2011

Explanation / Answer

#include <stdio.h>
#include <stdlib.h>

int main()
{
int day,month,year;
char *months[13] = {"",
"January",
"February",
"March",
"April",
"May",
"June",
"July",
"August",
"September",
"October",
"November",
"December"
};

while(1)
{
printf("Please enter an ISO Date into the program (yyyy mm dd)");

if(scanf("%d%d%d",&year,&month,&day))
{
if((month>0&&month<13)&&(day>0&&day<30))
{
printf("Date : %s %d, %d ",months[month],day,year);
break;

}
else
continue;

}
else
{
printf(" ");
continue;
}

}

return 0;
}

OUTPUT:
Please enter an ISO Date into the program (yyyy mm dd)1 2 2011
Please enter an ISO Date into the program (yyyy mm dd)2011 2 1
Date : February 1, 2011

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote