0 like 0 dislike
7.9k views

Write a program that prompts the user to enter two dates and then indicates which date comes earlier on the calendar (m/d/yyyy):
 Sample input:

3/6/2008
5/17/2007

Sample output:

5/17/2007 is earlier than 3/6/2008

 

Sample input:

3/6/2007
5/17/2008

Sample output:

3/6/2007 is earlier than 5/17/2008

 

Sample input:

3/6/2007
3/6/2007

Sample output:

Same day!

 

[Exercise] Coding (C) - asked in C
ID: 22673 - Available when: Unlimited - Due to: Unlimited

edited by | 7.9k views
0 0
Called for Help

56 Answers

0 like 0 dislike
Hidden content!
**** ** ****** *** *

int main (void)

{
* ***** * ** * * **** dd, yyyy, mm2, dd2, yyyy2;
* ** ** ***** * *** * * * **** ** first date *** * * ***** **
* *** ** * * ** * ** * *** * * ** **** * ** * * ** * ***
** * * **** ******** * * *** second date ** ** * * **** *
* ***** ** *** **** **** *** ** * ** ** * * * ** *


**** * * *** (yyyy * * yyyy2)
* * *** *** * *
** ** *** ** * *** ** ** ** * * *** * * **** * * is * than *** * mm, dd, yyyy, mm2, dd2, ***
** **** *** **
* ******* **** * if (yyyy ** ** yyyy2)
** ** ****** * **
******** ** *** * *** ** * *** * **** * *** *** * * is earlier than ** * ** *** mm2, dd2, yyyy2, mm, dd, yyyy);
* ** * ** ** **
**** ** * ****** ** if (yyyy == yyyy2 ** ** * mm ** * mm2)
* * * ** ** * *
** * *** *** * ** * * ** * *** * *** ** is earlier than ** * * * * mm, dd, yyyy, mm2, dd2, * * *
* ******* * *** * * *
** ** *** **** ** * * if (yyyy == yyyy2 ** * ** * mm ***** mm2)
** * **** * **
* * *** *** * ** ** * * * ** ** ** * ** * * * * is * * than * * * * mm2, dd2, yyyy2, mm, dd, yyyy);
** * * *** *
* *** * * * ** if (dd * ** dd2)
** **** *** ****
** ** * * * * * * * * * * * * ** ** is ** than * ** ** * *** mm, dd, yyyy, mm2, dd2, yyyy2);
* * * ** *****
**** * *** ** * **** ** if (dd2 *** dd)
* * * **** * **
* ** * ** *** ** * * *** * * is earlier than ** * ** ** ** * mm2, dd2, yyyy2, mm, dd, yyyy);
* * * ** * ** *
* * * ***** *
* * ** ** ****
* ** ** ** * *** * ******* * * * **** * * ** * * dates you ** * are the ** *
** **** *** ***
** **** * ** *** * 0;

}
answered by (44 points)
0 like 0 dislike
Hidden content!
#include **** * * *

int main(void)

{
* * * *** * ** * * ** * *** m1, m2, d1, d2, y1, y2;
* ** ** *** **** *** * * ** **** * &m1, ** * *** *
** ** ** * * *** ** **** ****** * *** * &m2, &d2, * **


*** * *** ** **** * ** * * * *
* * * * ** * * * *** * * *** * * * * ** **** * ******* is earlier than * **** ** * * d1, y1, m2, d2, y2);
*** * *** * * *** **
*** ** * * **** * **** * * * * * * ***** **** ** * is earlier than * * **** d2, y2, m1, d1, y1);


* ** *** * * * * * ***** *** (y1==y2)
* * ** ** * *** ***** *****
* ** ** *** ** ** *** * * * *** ** ** * ** ***** * * ** **** * * ** * * is earlier than * * *** *** d1, y1, m2, d2, y2);
* * ** *** *** * if ** ***
*** * * * * **** * **** * ********* ** * *** * ** * **** * is earlier than * * * *** ** * * d2, y2, m1, d1, y1);}


*** * *** ** * *** ** (y1==y2 ** * m1==m2)
** * *** * ** * * ** * ** * ** *
***** * ** * * * * * ** ** * *** * ** ** *** * * * is earlier than * * ** *** * ** d1, y1, m2, d2, y2);
* * * * * * * * * *
*** **** *** ** * ** * * * * * * *** ** *** * ***** * is earlier than * ** *** ** d2, y2, m1, d1, y1);}


* ** * ** * *** ** ******** * 0;



}
answered by (38 points)
0 like 0 dislike
Hidden content!
#include <stdio.h>



int main()

{
*** * ** * ** * * * a,b,c, a1,b1,c1;
* ** * * *** *** * ** * * ***** ** ** &a,&b,&c);
***** * ** *** **** * ** ** ******* * * * **


* * * *** * * *** ** == c1 && b == b1 && a ==a1)
** *** *** * * ***
* *** ** ***** * * ** ****** ** *** *** * * *** ** ** * day!");
** * * **** ** ***** ***** if(c < c1)
** * ** ** * ** * ** *
* ** * * * * *** * * ****** *** *** * *** *** ***** ** * * * is earlier than ** * **** * ** * *
** * * ** * **** ** *
* ** ** ** * * * * *** **** if(c > c1){
********** * ** ** *** **** *** ** *** * ** * * * * ***** *** is earlier than %d/%d/%d",a1,b1,c1,a,b,c);
***** * * ** * *** ******* * if(c == c1)
* * * * * * ************* ** *
* * *** ** * ** ***** * **** ** * **** * ** ** < b1)
**** **** ***** * ** * * ** *
* * * * * * *** **** ** * **** ** *** ** **** ** * ** ****** **** is earlier than * * **** * ** * ** *
** ** * * * ****** *** *** **** * ** ** *
* *** ** * * * * **** * * * * * * * * ****** * *
**** * * ** * * *** * * * ** ** *** ** ***** * * * **** * * * ** * is earlier than %d/%d/%d",a1,b1,c1,a,b,c);
** ** * * ** ****** * * * * ** * *
*** **** *** * ** * else if(c == c1 && b == b1)
* * * ** ** *** ** *
** * *** * **** ***** ** ******* * *** * ** * * < a1)
** ** * ** * * *** *** *** * * * *
* * * ******* ** * * * *** * * * *** *** ******** ** **** * **** *** ** ** *** is earlier than %d/%d/%d",a,b,c,a1,b1,c1);
* *** *** * * ** ** * ***** ** * * * else{
** ** * * ******* * * * * * ** *** *** **** * * * * **** ** ** * * ** is earlier than %d/%d/%d",a1,b1,c1,a,b,c);
* ** * * * * * ** * *** * *** * * ** ** * * **
*** ** **** * * * * *










* * ** * ** ** ** ** **** ** 0;

}
answered by (-189 points)
0 like 0 dislike
Hidden content!
#include <stdio.h>

#include <stdlib.h>



int main(void)

{

   

    int date1[3],date2[3],i;
** * ** ** * * * ** * * * ** * ** *** **** *** ** ** ** **** * * * ** ** ** *** * * ***
* * * * *** **** * * ** ****** * * ** *** * * * ** * ** *** * ** * * *** ** * *


* ****** ** * ****** * * * ** ** ** * *** ** * ** ** ** * **
* * *** * *** * * * * * * ** *** *


** * ** ** * ** ** ** ***** **** * * * ***** **** * * ** * * * * ** ** * * *** *
***** **** ** * ** ** ** ** * ***** * * **** * ** * *** ******** *
* * * ** * * * * * * * * * * ** ** **** *** *** * *** ** ** * **** ***** *** * * ** * ****** *** is earlier than %d/%d/%d\n",date1[0],date1[1],date1[2],date2[0],date2[1],date2[2]);
** * * ** ***** * * * **** ** * *** ** ** * ** ** ** ** * *** *** * * * ** * ** * *
** * * * * * *** * * * ** * ** **** ** * * * * * * * * ** **
* ***** ***** *** * * **** *** * *** **** * ** ** ** if(date2[i]<date1[i])
* * * * **** ****** **** **** ** ** ******** * * * * ** *** * * *
*** *** ***** ** * * ****** * * ** * ** * * *** *** *** * *** *** * ** * ** * * *** * * ****** is earlier than %d/%d/%d\n",date2[0],date2[1],date2[2],date1[0],date1[1],date1[2]);
** ** * *** * * *** * ** *** * * **** ***** ****** ** * ** ** ****** * * *** * ** ** ****
* *** * * * * ** * * * ** * * * * * * * **** * * *** * ***




* ** ** ** ** * * * ** **********
** * *** *** ** ** ** ** ** ** * * ** **** ** * * ** ** * ** * day!\n");

    return EXIT_SUCCESS;

}
answered by (0 points)
0 like 0 dislike
Hidden content!
#include *** ** * ***

int main(void)

{
* *** ** ** ** m1, m2, d1, d2, y1, y2;


* * ** * *** * ** * * ** **** * * * first date (mm/dd/yy): * ** *
* *** * ** * * ** ** * * * *** * ** * ** &m1, * ** ** * *


* *** *** * ***** * ** ** * second date (mm/dd/yy):
** ** * **** * **** ** **** ** * * * * * &d2, * **


* * ** * *** ** * ** ** * **** *
* * * ** ** * * ** **** * * ** ** * ** * * ** * * * ** ** ** *** is earlier than * ** ** ** * **** d1, y1, m2, d2, y2);
*** **** * ***** * ** ******
* * ** *** **** * * * * *** * ********* * ** ** * *** is earlier than * * * ******* d2, y2, m1, d1, y1);


* * ** * ***** ******** * ** * (y1==y2)
**** * ** * * ** ** * * ** ***
***** * ** * * **** ** * *** * * ** * * **** *** ** ****** * ** *** * ** is earlier than ** *** ** ** * d1, y1, m2, d2, y2);
* ** * * ** *** * if * *****
**** * * * ** * ** ** * ** * ****** ** * * * is earlier than ** ** **** * d2, y2, m1, d1, y1);}


** * * * ** * (y1==y2 ** * * ** * m1==m2)
* * * ** *** **** * ** **** ****
* * * ** ** ****** * * * * * * *** * ** * * ** * * * * * is earlier than *** ** ******** d1, y1, m2, d2, y2);
** *** *** ****** * **
* *** * ***** ** * ** *** * * ** ** ** ****** ** * ****** is earlier than * *** ** * * ** d2, y2, m1, d1, y1);}


* * ***** **** ** 0;



}
answered by (44 points)
0 like 0 dislike
Hidden content!
#include ***** ** *

#include ** * *** *



int main()

{
* * * ** * * * *** ** a[3], b[3], i;
* * ** * *** ** **** * ** **** ** &a[1], &a[2], * * **
*** * * ********** * ** * * **** &b[1], &b[2], ** ****
* * *** * * **** * * i<3; i++)
* *** ** *** ** * *
** ** * * * * ***** * * * ** ** ** * ** * * * ** * * * ** *****
* **** ** * * * * ** ***** * * ** **
*** * ******* * * ** *** **** ** * **** **** ** *** * ** *** * ********* * * ** * is earlier than * *** * ** b[1], b[2], b[0], a[1], a[2], a[0]);
* * ***** * * ***** ** *** * * * * ** ** * *** ***** *** **
** ** **** * **** *** ** ** **** **** * *
** ** * ** * * ****** *** * *** *** ** ****** if(i==2) *** * **** * * is earlier than **** * a[1], a[2], a[0], b[1], b[2], b[0]);
*** * * * **** * *


** * * * * * ** ** * 0;

}
answered by (-364 points)
0 like 0 dislike
Hidden content!
**** *** * *** *



int main()

{
** *** ** * **** ** day, month, year, day1, month1, year1;
* ** * *** **** * * ** ** * * ****** * *** * * ** * ** * * *
* * * *** * *** * * *** *** * ** * * ** * ** *** * ** * **
* ** * **** * * ** *** * (year1 **** year)
* * * * ****** ** ** ** ** * ** *** **** * * ** *** *** is earlier than * ** * * month1, day1, year1, month, day, year);
** *** * * ***** **** * ** if (year1 == year ***** * * month1 == month ** * ** day1 == day)
** ** *** ** ** * * * ******** * *** * * *** * * ** * ** *** *** **
* * * * ** ** **** if (year1 == year)
* ** ** ********* * * *
* * ** ** * * * *** ** * * * * * * * (month1 ** * month)
**** * *** **** * * * ** * * ** **** * ** ** **** *** ****** * ** **** ** * * is earlier than * ** ** day1, year1, month, day, year);
** * *** ** * *** * **** ** **** *** *** if (month1 == month)
* **** * **** *** * * * ** * ** * **** *
** * * **** * * ** *********** * ** ** ** * * **** ** ***** (day1 *** day)
*** * * ** ****** * * **** ** ** * * **** * * *** ** ** *** **** ** * * * **** *** ** **** *** * ****** is earlier than * ** * month1, day1, year1, month, day, year);
** *** * * * * *** *** * **** ****** * * **** * **** * *
* ** * *** ** * *** **** **** * * ***** ** ** *** ******** ** **** * ** * **** **** **** * ** * is earlier than ** **** month, day, year, month1, day1, year1);
***** * * * ** * * ** * *** *** *** * *
* * * ** * * ** *** * *** * ** ** * **
* ** * * * * * * ** ** ****** ** *** * *** **** ** ** * * *** is earlier than ** *** month, day, year, month1, day1, year1);
*** *** * * ***** ** *
** * * *** ** ** * ** *
* *** * * * * **** *** * ** * * * *** * * is earlier than * ******** month, day, year, month1, day1, year1);
** * *** *** *** * * *** ** * 0;

}



// *** * *** *** is earlier than ** * ** day, month, year, day1, month1, year1);
answered by (-218 points)
0 like 0 dislike
Hidden content!
#include<stdio.h>



int main(void)

{
******** ***** * * *** * month1,date1,year1,month2,date2,year2;
** ** ** * *** ** *** * ** *** * ** * *** * * * * * *** * ***** *
* * *** * ******** ** * ********* * ** *** ***** ** **


* *** * ****** * * *** **** * * * ** * *
*** ** * *** * ***** **
** ***** * ** * * * * * *** *** ** *********** ** * * ** * *** * is earlier than ***** * ** ***** ** ** ** *** * **

    }
* * * * * ******* *** ** if(year2>year1)

    {
* *** ** * * * * ** *** * ******** *** ** * * * *** is earlier than * *** * ************* * * ** * **
* * * * ***** * * *
** * *** * ** if(month1>month2)
*** *** * ** ** *** ** * * *
** * * * * ** * * * *** ** ** ** ** * ** ** ** is earlier than * * *** * * * * **** ** * * ** *
* *** ** *** ** * * *
* ** * ** *** **** if(month2>month1)

    {
* **** ** * ** * * * * **** ** ** * *** ** * ****** *** * is earlier than ********** *** * * * * * ** * *
* * * ** * ** * ** *** *
* ** * **** ** * * ** if(date1>date2)
** * *** * **** *
* ******* * * * * *** * *** *** * ** ** **** * **** *** is earlier than * * * * * * *** * ** *** **
** * *** *** * * * ****
* ** ** ** * * if(date2>date1)

    {
* *** * * ** * *** **** * *** ** * ** ** is earlier than ** ** * *** * * * ** *
* * ** * **** ** **** * *
***** ** * ** * ***
** * ****** ** * *
* ** * ** * *** * * ******* * * *** * * ** * * * ** ** day!");
* * *** ** **** * ** **

}
answered by (-412 points)
0 like 0 dislike
Hidden content!
#include ** * *

int main(void)

{
* * * * * * ** m1, m2, d1, d2, y1, y2;
* * * *** ** * ** * * * *** * *** * ** * &d1, ** * ****
* * ** * * ** ** * * * * * * * * * **** &m2, * ** * * * *


* *** ******* * * **** ** * ** **
* * * * * ** * ***** ** *** * ** * * ** ** ** * * ** is earlier than **** * * ** d1, y1, m2, d2, y2);
***** * ** ***** * * * * *
** * * * * * ** * ** ** * ** * * ** * * * * * *** * ** * is earlier than **** ******** * * d2, y2, m1, d1, y1);


* * * *** ** ** * (y1==y2)
** * *** * ** * ** ** * *** *** ****
* ** *** * ** ** * *** **** *** * ****** * *** * * *** * **** ** ** * *** * is earlier than * * * **** * d1, y1, m2, d2, y2);}


* * * **** * * ** *** * * (y1==y2 * * **** m1==m2)
**** **** * * * * ****** ** ** *
*** ** * * * * * ** *** * * * *** * ** * * * ** is earlier than ***** ** * * d1, y1, m2, d2, y2);

}


* ***** ** * ** * * ** 0;

}
answered by (38 points)
0 like 0 dislike
Hidden content!
#include <stdio.h>

#include <stdlib.h>



int main(void)

{

    int date1[3],date2[3],i;
** ** ** ** * *** *** ****** * ** ** * ** **** ** ** *** ** ****** * ** ** * * ** * * * * * * * *** *
** * * * * * * * *** *** ** ** ** * ** ** *** * * **** * * ********** * ***** *


* ** * *** ** * * * ***** * ** * ** * * ** **
** * * * ** ** * *** * ** ** *** ** *
* * ******* * *** *** ** ** **** * ** * ** * ** *
***** **** * * *** * ***** ** * *** *** * * ** * * ** * ** ** * * ** *
*** * * * * * * ** * ***** ** * *** * * *** **** ** ***
**** ** * ** * * * * * * ** *** * * * *** * *** * ** * *** ** * * ** ** ** * * * is earlier than %d/%d/%02d\n",date1[0],date1[1],date1[2],date2[0],date2[1],date2[2]);
* * * * * ** ** *** *** * * * *** ** *** * *** * ***** ***** ******** * * *
*** ** * * * * * ** * ********* * **** ** *** *** * *
*** *** *** * ** * ******** ** * * **** *** * **** ** **** * * * if(date2[i]<date1[i])
** * * *** * *** *** * ** * * **** ******* *** *** * * * * *
** * ** * * ** * * ** * *** * * * * * * *** ** ** ** * * *** ** ** * *** *** ** ** *** is earlier than %d/%d/%02d\n",date2[0],date2[1],date2[2],date1[0],date1[1],date1[2]);
** ** * * * * ** ** **** * ** * ** ** * * ** * * *** * ** ** **** ******** * * * * *


*** *** * ****** *** ***** * *** * * * ****** *** * * * * ***




** ** ** * ** * ** ** ** ** * *

    return EXIT_SUCCESS;

}
answered by (0 points)
Welcome to Peer-Interaction Programming Learning System (PIPLS) LTLab, National DongHwa University
English 中文 Tiếng Việt
IP:104.23.243.109
©2016-2026

Related questions

0 like 0 dislike
50 answers
[Exercise] Coding (C) - asked Mar 16, 2017 in C
ID: 22973 - Available when: Unlimited - Due to: Unlimited
| 7.1k views
0 like 0 dislike
82 answers
[Exercise] Coding (C) - asked Mar 9, 2017 in C by thopd (12.1k points)
ID: 22674 - Available when: Unlimited - Due to: Unlimited
| 10.3k views
0 like 0 dislike
111 answers
asked Mar 16, 2017 in C by thopd (12.1k points) | 15.3k views
12,783 questions
183,442 answers
172,219 comments
4,824 users