Answer to Question #29505 in C++ for Chake
Write a program which inputs the date in the format dd/mm/yy and outputs it in the format month dd, year.
1
2013-04-30T08:49:07-0400
#include<iostream>
#include<stdio.h>
int main(){
char * s = "25/12/61";
char * month = (char *) malloc (10 * sizeof(char));
int y, m, d;
d = ((int) s[0] - 48) * 10 + (int) s[1] - 48;
m = ((int) s[3] - 48) * 10 + (int) s[4] - 48;
y = ((int) s[6] - 48) * 10 + (int) s[7] - 48 + 1900;
if (m == 1) month = "January";
if (m == 2) month = "February";
if (m == 3) month = "March";
if (m == 4) month = "April";
if (m == 5) month = "May";
if (m == 6) month = "June";
if (m == 7) month = "July";
if (m == 8) month = "August";
if (m == 9) month = "September";
if (m == 10) month = "October";
if (m == 11) month = "November";
if (m == 12) month = "December";
printf("%s %d, %d", month, d, y);
getchar();
return 0;
}
Need a fast expert's response?
Submit order
and get a quick answer at the best price
for any assignment or question with DETAILED EXPLANATIONS!
Learn more about our help with Assignments:
C++
Comments
Leave a comment