0 like 0 dislike
4.3k 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 | 4.3k views
0 0
Called for Help

56 Answers

0 like 0 dislike
Hidden content!
#include <stdio.h>

int main(void)

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


** ** * ** *** ****** (y1<y2)
** * * ** * * * * *** ****** ******** **** ** ** *** ** * is earlier than * * * * * *** d1, y1, m2, d2, y2);
*** * * *** *** * *** if (y1==y2)
* * ** * ** * ** ** **
* *** * * * * ***** * * * * * * * *** ** *** ** (m1<m2)
* * ******* ** ** * * ** * **** ** * * ** ** * ** ***** * * **** * * ** * * * * * is earlier than * * * * * ** * d1, y1, m2, d2, y2);
* **** ** * ** ** ** ** *** * ** * * *** * if (m1==m2)
* * * * ***** *** *** ******* **** * **
* **** * ** ** *** * ** * ** * **** *** * * * ** *** ** *** * ** (d1<d2)
* ****** *** * ******** * * * * * ** ** * * * *** ** * ** * * * ****** * ** is earlier than %d/%d/%.2d\n",m1, d1, y1, m2, d2, y2);
* ** * * *** ** ** * ** * * ** * * ** ** * * * * * * ** if (d1>d2)
****** ** ** **** * *** *** * * * ** * * ** ** * * ***** * * * * ** ****** * *** ***** *** **** **** *** is earlier than **** * * *** d2, y2, m1, d1, y1);
* * ** *** * * * * * * ** ** * ****** ** * * ****** ** ** * ****** * * *
** ****** * * * ** * *** * * ** *** ****** *** * *** *** * *** *** ** ** ****** * * * ** ** ** ** day!");
* ***** * ** ****** *** * *** ** *** ***
* * ** *** * ****** **** *** * **** **** * **
* * *** * * ** * ** * *** ** ** ** * * ** ** * * ** ** * * ** *** ** ** ** is earlier than %d/%d/%.2d\n",m2, d2, y2, m1, d1, y1);
*** * * ***
* ** * * ** * *** ** *
****** **** * * * **** * * * **** ** ** **** * * * ** ** is earlier than %d/%d/%.2d\n",m2, d2, y2, m1, d1, y1);


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

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



int main()

{



int ******* *

int n[10];


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


** **
** * *********** * * ** * is earlier than **** ** *** * **
* * * * * **** if(c<=f * * *** a<d)
* *** *** * *** ***** *** ** * ** is earlier than * *** ** **
* * *** * * ** * * if(c<=f * * **** * b<e * ** * ** * a<=d)
* ****** * **** * * * * * ** * * *** ** * * * * *** ** ** ***** * * **** is earlier than *** * * * *** ***


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









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



int main()

{



int * * ****

int n[10];


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


* *
* * * *** * ***** * * * ** is earlier than ****** * ** * *
** * * ** * ** *** *** if(c<=f ** ****** * a<d)
******** *** * ****** * * * * * is earlier than **** ** ******* ***
* * ** **** * ***** * *** * if(c<=f ** ** ***** ** b<e * * * * a<=d)
** * * *** * *** * ** *** * ***** * * * ** **** ** *** is earlier than **** * * ** *******


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









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

#include<stdlib.h>

int main()

{

    int year1,year2,month1,month2,day1,day2;
* *** *** * *** * * ** * ** *** ** ** ****
* ** **** ** *** *** * * * * * ** *** *
*** * ** *** *** * * ***
** ** ** ** *** * * ** * * * * ** ** * * * * * is earlier than * ****** *** *** * *** * * *

    else if(year2<year1)
** ** * ** *** * * * * ** ** *** *** * * ** *** is earlier than * * ***** ** ****** * * * **

    else

    {
** **** * ** * * * ** * * * * ***** * ****
* ** ****** * * * **** * **** * ** ****** * * *** * *** * ** * ** * * * is earlier than * * ** * *** * * ** **** * *
* * * ******** * **** * * * ***** **** * *** if(month2<month1)
* * *** * * * **** *** ** * * *** * * * * * ** *** * *** *** *** *** is earlier than *** * ** ** * * * ** * **
*** * *** ** * * * * * * * ** *** ***** ***
** * * * **** * ** ** * **** * * * ** *** *
* ** ** ** * * *** * *** ** ** * * * * *** ******* * * * * ** *
*** * *** * * ** **** *** * * ***** ** * * * ** ** * * * * *** * ** * * * * *** ** ****** ** is earlier than ** * * * * **** ***
***** **** * *** ******* * ** ** * * ** * *** ** * *** *** * * * ** if(day2<day1)
* * * * **** *** * * ******* ** * * * *** *** * * * * **** ******** ** * * * * ** ** * ******* is earlier than ** * * * ** *** * *** ** * * ** **
**** ** * ** * ** * **** ** * ** * ******* * ***** *** **
***** * ***** **** * ** ** ****** **** ** ** ** ** **** *** **** ***** ** *** * *** **** * day!");
* * ** **** *** ** * * *** **** *** ** ***** *

    }

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

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

#include<stdlib.h>

int main()

{

    int year1,year2,month1,month2,day1,day2;
** **** *** *** ******* *** * * * ** * **** **** * *
*** * **** ** *** * ** ** ** * ** **** * *
** **** ** * **** * ** **** * **
** * ** ******* * * * * ***** * * *** * * ** * * * is earlier than * **** *** * *** *** * ** *** ***

    else if(year2<year1)
* * * ** ** * ** ** * * ** * ** ** * *** *** is earlier than * ** ** * * * * * ** ****** **

    else

    {
*** ** ** ** ***** * * *** * * * ** * *
*** *** ** * **** * ** ** * ** * * * ** ** * * ** * ******* * is earlier than * * * ** * ** ** * *** *
** * **** * * * * * * * * ** ****** * * ** * ** if(month2<month1)
** * * * ******* ** * ** *** *** ***** *** * * ** **** * ** ***** ** is earlier than * * * ** ****** ****** *******
** * * * ****** ** ** ** * * * * ***** *
* ** * ** * * *** * * ** * *** **
* * * * * * * *** * **** * ***** * ***** ** * * * * ** *** ** * ********
** * ** ** ***** * ****** *** * ** * ** * * * ***** *** * ** **** * * ** ** * * * ****** ** is earlier than * ** * *** ** **** ** * ** *** *****
* ***** * ** ** * * * * * * * ** ** ** ** ** * * *** * * if(day2<day1)
* * ** ** * *** * * * ** ** *** ** **** ** * ***** ** ** * * ** * * *** * *** * * ** ** ** * ** is earlier than *** ** * ***** * * ** * * ** *
**** * * * ** *** *** ** *** ** * **** * * * * ** * ** *** * **
** *** * * * * * ***** ** *** ** * ** ** * * ** * * * * ******** * * ** * ** * * **** **** ** day!");
*** *** ***** ** ****** ** *** * ** *** *

    }

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

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

#include<stdlib.h>



int main(){
****** * * * *** ** a[3];
****** **** * ** * ** b[3];
****** * * * * * * ** ** * * * ** * ****** *** * ***** * *  //day,month;year
** * *** * ** * **** * * ** * * ** ** *** * *** * * * * *** *** ** * ** *** * * **
** ** *** * ***** * ** * * > b[2]){
* ** * * **** *** **** * * * ** * ** * * ** * *** * * * is earlier than * * *** ** **** ** ***
** ** * ******* * * ** ****** * ** * ** * 0;
** ** *** ** * * ******
** ** * *** * * if(a[2] < b[2]){
* * ** *** **** **** *** ** * * * **** ** * * ** ** * is earlier than * * ** **** ** * *** *
* *** **** * ** ** * *** **** *** * * * * 0;

    }
* * ** * ** * if(a[1] > b[1]){
* * * * *** * ** *** ** ** ** * ***** * * ** * ** is earlier than * **** * *** ** **
** * * *** * ** * ** * **** *** * * 0;
* * * ** * * * *** * *****
** *** * ****** * ** ** if(a[1] < b[1]){
** *** *** * **** ** * *** *** * *** ** * is earlier than * ** * * ** *** * ** * *****
* * * ** *** *** ** * * ** ** **** *** ** ** * 0;

    }
** ** ** *** ***** *** if(a[0] > b[0]){
* ****** * * *** ** * *** ** ** ** * ** *** * * * * * is earlier than * ** ** * * * * * *** * *
** * ** * ** ** *** * ** * ***** 0;

    }
* ** ** ** **** *** ** if(a[0] < b[0]){
* * * **** *** *** ** * * * * * * * * is earlier than * ** ** ***** * **
* * * * * * * ** ***** ** * *** ** * ** 0;
* * * ***
*** * * * * *** ** **
* * * ****** **** *** **** **** * ** ** * * ** * day!");
** * ** **** * ***** *** **** * * *** * * * 0;

    }

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



int main(void)

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


** * * ** * ** ** ********* * *** * * * * &m1, &d1, &y1);


* * * ** * *** **** * *** * **** * ** &m2, &d2, &y2);


** ** * * ** * ** * * (y1 < y2)
* ** * ** * ** ***
* * * * * * ** * ** * * * ** ** * **** * * **** *** * is earlier than %d/%d/%.2d\n",m1, d1, y1, m2, d2, y2);
** * ** * * **** *
** * **** ** * ** if (y2 < y1)
** * * ** ** ** ** *
******* * * ** ** ** ** * * * * * * * ** ** * * * * * is earlier than %d/%d/%.2d\n",m2, d2, y2, m1, d1, y1);
** * * **** * * *


* *** * **** * *** (y1==y2)
** *** * *** * ** * * ***
* ** ** * * **** * ** *** ****** ** ** (m1<m2)
* * * **** * *** **** ** **** * ***** ** * * * ** ** ***** * *** *** ** * * ** is earlier than %d/%d/%.2d\n",m1, d1, y1, m2, d2, y2);
**** * ******** * * * * *** *** * * *** ** * if (m2<m1)
* ******** ******* * * * ** * ***** ** ** * ** ** * * * * ** * ** *** * * is earlier than %d/%d/%.2d\n",m2, d2, y2, m1, d1, y1);
* ** **** ** *** * *
* ** * ** * * ** (y1 == y2 && m1 == m2)
* *** * ** ******** *
** * * * ** * * **** * * * ** * ** (d1 < d2)
* **** *** * ********** *** * **** *** *** ***
* * * * ** * ** * **** * *** ***** * * * **** ** * ** *** * * * * ***** * is earlier than %d/%d/%.2d\n",m1, d1, y1, m2, d2, y2);
* * *** * * * *** ** * ** * * * * * * **** *
**** ***** ** *** * ** ** * * *** * * *****
* * ** ** * *** ** * * * * ** ** **
** ** ** *** * * *** ** ** *** * ***** * * * ** ** *** * **** * * (d2 < d1)
**** ** * * **** *** ****** ** ******* ****** *** * ** ** * ******* * * * **
* *** * ********* * ** *** ** * * **** * * * * * *** * *** * ** * * *** * * ** ***** *** * ** ** * is earlier than %d/%d/%.2d\n",m2, d2, y2, m1, d1, y1);
* ** * *** *** * ** * * * ******* ** ** * * * ********** * * **
* **** ** ** ** *** * * * * ** * ** * * *** ***** ** * ** * **** *
* * * *** ** ** ** ** ** *** **** ** * * * * * * *** ** ** *** ***** *
* **** **** ** * * * **** * * ** * *** * * * ** * * * * ***** **** * * * * * *** ** * **** * * day!\n");
** ** * * ** **** ** * ***** * ** **** ** ** * * *** ** *** ** *
* * **** **** * * * * ** * ** *
* ** * ** *** ** * * ***


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



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

#include<stdlib.h>



int main(){
**** ** * * *** * a[3];
* ***** * ** ****** ** b[3];
* * ** * **** ** ** *** ** ** * ** * * * **** * ** ** * ***  //day,month;year
* *** * * *** * *** * ** * * * * ** * * *** **** *** *** * * * * ** * ****** ***
** ** * ** * ** * * ** ** > b[2]){
* * ** *** * * * * * ** * * * * ** * *** * * ** *** is earlier than * * * * * * ** ** *** **
** ***** * **** ** * **** * * *** * * 0;
* * * * * ** * **
*** **** * * * * ** **** if(a[2] < b[2]){
*** * * * * * * * * ** *** * ** * ** ** * * *** is earlier than * ** * * ** ** *
*** *** ******** * ** ** * *** ***** * * ****** * 0;

    }
* * *** * ** * ** * * if(a[1] > b[1]){
** ** * * *** ** *** **** ** * * ** *** ** *** ***** * is earlier than * * ***** **** **** * *
* * * *** ** * * ** * * * * ** * * **** 0;
** ****** * *** ** *
* * ** ** * ** ** * if(a[1] < b[1]){
* * * ** * ****** * ** * * * * * *** **** ** * * * * is earlier than * *** * * **** * *** ******
****** *** **** ** *** **** * ** **** ** **** ** 0;

    }
** * ***** ** *** ** if(a[0] > b[0]){
****** *** ** ** ** * ** *** * * * * *** *** *** is earlier than ******* *** * * *** * *
** * * ** * * * * * ** * * *** **** * * 0;

    }
*** **** * * *** * if(a[0] < b[0]){
* ** * * ** ** ** *** ***** *** * * ***** * * is earlier than *** *** * * **** * ** * *
** ** ** *** *** * * * * ** * ** ** * * * ** ** 0;
* * *** * * * * **
* ** ** ** * *** * ***
* * * * ** * ** ******* ** *** * ** * ** *** * * * day!");
** * * ** * * **** * * *** * ** * *** * * 0;

    }

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



#define FIRST_DATE_IS_BIGGER (1)

#define SECOND_DATE_IS_BIGGER (-1)

#define DATES_ARE_EQUAL 0



int main(void)

{
** * *** * * *** * m1, m2, d1, d2, y1, y2;
* *** * ** * * ** result = DATES_ARE_EQUAL;


** *** ** *** * ** * * ** * * *** ** the first date (mm/dd/yy): ");
* * *** * ** ** ** ** ** * *** * * ** * *** * &m1, &d1, &y1);


* **** ** ** * *** ** ** **** * the second date (mm/dd/yy): ");
* * ** ** ** * * **** * ** * * * **** &m2, &d2, &y2);


* * * *** * * *** **** (y1 < y2) {
** * * * * **** * ***** ** **** ** * *** * *** * = SECOND_DATE_IS_BIGGER;
* * * * * * ** * * *
* * * ** ** *** *** * ** ** if (y2 < y1) {
* * * * *** * ****** * *** ** **** *** * * * * = FIRST_DATE_IS_BIGGER;
* * * ** ****** *
* *** ** ** * * * ** *** {
** ** ****** ** * * ****** * ** ** ** *** * * * (m1 < m2) {
* **** * * **** * * ** ***** * * * * * * ** ** ** * = SECOND_DATE_IS_BIGGER;
** ** * * * * * ** * * *** * * **
* * * * * * * * * *** ** ****** * ****** ** * if (m2 < m1) {
** * ** ** **** * * * * * * * * ** * * * *** * * *** * = FIRST_DATE_IS_BIGGER;
* * * * * * * ** * * * * * * * * * *
* **** ** ** ** **** *** * * ** * * * {
*** * * ** *** ** ** **** * * ** * * * * *** * *** (d1 < d2) {
** ** * ****** *** ** ** * * * * * ** * *** **** * *** * ** **** * * * ** * * * ***** ** = SECOND_DATE_IS_BIGGER;
** ** * *** * *** ** * * *** * ** * ** * * **** * * ****
* **** ** ** * * * * *** **** * * **** **** * ** * * ** * * * *** if (d2 < d1) {
* * ** * * ** * * ** * * **** * ** ** * ** * * ** * * ** * * ** * *** * = FIRST_DATE_IS_BIGGER;
* ***** ******* * ** * *** ******* * * *** * ** ** *** * ** *
******* * ** * *** ** * *** * * * ** * ** ** **
* * **** * *** * * * ** *


* * * * ** * * **** * *** (result) {
** * ***** * ** * *** * * ** ** * ***** * ****** FIRST_DATE_IS_BIGGER:
**** * ****** **** ** * ** * *** **** * * * ** * * * * ** ***** ** *** *** * is earlier than * ** *** ** ***** d2, y2, m1, d1, y1);
** ** ** * *** * * * * * * * * **** * ** ** ** ***** ** * * * *
* ** ** * * ** ** * * ** * ***** * * * * SECOND_DATE_IS_BIGGER:
* * ****** * ** * ** * * * * * * ** **** *** ** *** * * *** * * ** * * * * * is earlier than ***** * ** **** d1, y1, m2, d2, y2);
* ** * ** * * ***** * * * ** ** * * **** *** *** * *** ***
** * * * ** * *** *
* **** ** ** * *** 0;

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

#include ** * **** * *



int main()

{
*** **** * ** * * * ** a[3], b[3], i;
*** ** ** * * * * ** ****** * ** &a[1], &a[2], &a[0]);
** * ** * *** * * *** *** *** * *** * ** * ***** ** &b[1], &b[2], &b[0]);
* *** * *** ** *** **** * *** * * *** * * * ** ** **** * * day!");
** *** *** * **
*** * * * ** *** *** ***** 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)
Welcome to Peer-Interaction Programming Learning System (PIPLS) LTLab, National DongHwa University
English 中文 Tiếng Việt
IP:108.162.216.108
©2016-2025

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
| 4.2k 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
| 5.8k views
0 like 0 dislike
111 answers
asked Mar 16, 2017 in C by thopd (12.1k points) | 8.6k views
12,783 questions
183,442 answers
172,219 comments
4,824 users