60 469
Assignments Done
98,1%
Successfully Done
In April 2018

Answer to Question #29505 in C++ for Chake

Question #29505
Write a program which inputs the date in the format dd/mm/yy and outputs it in the format month dd, year.
Expert's answer
#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!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions