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 * * * **** * **

#include ** * **



int main()

{
* * * * * * **** month, day, year, month2, day2, year2;


* * *** * * * * *** **** ** **** Date in m/d/yyyy ** * * ** *** *
**** ** *** ** ***** * *** ** *** * ** &month, &day, &year);


* * ** * * * * *** * ** ** Date to be compared, same ***** *****
****** ** ******* * * * **** * * * * *** **** ****** *** * &day2, &year2);


* *** ** * *** ** * *** ** ** month, day, year);
** *** ** ** * * ** * ** * * ** * * ** *** * month2, day2, year2);


* * ** * ** **** **** ** ** ** **** * * * *** * *
* * * * ***** *** * ** ** ** * * * * * ** ** ** ** * ** * * **** * * ***** ** * ** * *** * * **** is earlier than ** * * * **** month, day, year, month2, day2, year2);
* ****** *** *** ***** * ** *** ***** * * * * ** * * *** if ****** * *
** * ***** ** * * *** ** ** ** ** * *** ** *** * ** *** *** **** ******* ** * ** ** ***** * is earlier than * * ****** * month2, day2, year2, month, day, year);
** * * **** * *** * * * * ** **** ** ***** * if (year==year2 * * * ** **********
* * *** * ** * * * ** *** * ** *** ** **** ** * * *** ** * * * ******* ** * * * * ** * * is earlier than * * ** * * month, day, year, month2, day2, year2);
*** * * * ** * ******** ** ** *** if (year2==year * * ** * * *** **
*** * ** ** * * ***** * * *** * ** *** * *** * *** * ** * *** * ** * * * * * ** * ** ** * ** is earlier than ** ***** * month2, day2, year2, month, day, year);
** ** * ** * ** ** * * ** * *** * * if (year==year2 *** * * month==month2 **** * * ******
* * ** ***** * * ** * * * ** **** * * * * ***** * * ** * * ** ** * * ** * * **** * ****** is earlier than *** * *** month, day, year, month2, day2, year2);
** * ** * ** ****** * ***** * * ***** ** ** if (year2==year *** * ** * month2==month * * * * * ** **** *
*** ** * * *** * ** *** * * * * * * **** ** * * **** * *** *** **** *** *** *** * * **** ** ** ** * *** is earlier than *** * *** month2, day2, year2, month, day, year);
* * * **** * * * * * * ******* * * ** * * ** *
** * * *** ** ** ** ** *** * * ** ** *** ** * ** ** ** * * * * ***** * ** ** * ** ***** ** ** ** **


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

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

#include ******* ** ** *



int main()

{
* ** ** * ** *** ** * month, day, year, month2, day2, year2;


* **** *** * *** ** **** * ** ** Date in m/d/yyyy **** * * *
* *** * * **** * ** * * **** ** &month, &day, &year);


** * * * ** ** ** *** * **** ** Date to be compared, same * * *** **
**** ***** ** ** ** * *** * * * * ** ** * ** &day2, *** ** * *


* * ***** * ** *** * *** *** * * * ** ** *** * month, day, year);
*** ** * *** * * *** * ** * * ** ** * * month2, day2, year2);


*** ** ** * * ** ***** * ** *** *** **** *** * ** *** *
* * * *** * * **** * *** ** * *** *** * ** ** ******* * * **** * **** * * ** ** ** * ** *** is earlier than * * * * * ** month, day, year, month2, day2, year2);
* ***** *** * ****** ** * * ***** *** if **** * ** *
* * ** * ** *** ***** * * ** ** * ***** * **** * * *** *** * ** *** * ** ** **** ** * ****** * ** * is earlier than * * * * month2, day2, year2, month, day, year);
* * * *** * * *** **** **** * ** * * *
* ** *** * * * ** ** ** * ** * *** ** * ** ** ******** * *** ** ** ** ****** * *** * * * ** ****** *




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

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

int main (void)

{
* * * * **** ** * * * * ** dd, yyyy, mm2, dd2, yyyy2;
**** *** * **** **** * * * *** **** ** * * * *** *
* * ** * * *** ** *** * *** *** * *** * ** * ******** *
* * ** * **** * *
***** * * * * **** ** (yyyy < yyyy2)
** * * * * * ** **
* * * * * * * ** ** * * * ** ******* * * * * * * * * * is earlier than * *** * mm, dd, yyyy, mm2, dd2, yyyy2);
* * * **** * *
** * * ***** * * ** 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, yyyy2);
* *** * * ** ** **** *
*** * ***** * * * if (yyyy == yyyy2 * ** ** * mm * mm2)
****** ** * ** * *
** * ** * ** ** ***** * * ** *** ** ** * * ** ** is earlier than ** ** *** mm2, dd2, yyyy2, mm, dd, yyyy);
** * * **** ******** **
* **** * * *** * * ***** **** if (dd < dd2)
******* ** ** * * * ** *
*** ** *** * ** ** ** *** ******* * * * * * ** ** * is earlier than * *** ** mm, dd, yyyy, mm2, dd2, yyyy2);
** * *** ** ** *
* *** ****** * * * **** if (dd2 > dd)
* *** ** **** **** ** ** ** *
** * *** ** * * * * *** * *** ** ** * * * * is earlier than * * * * * mm2, dd2, yyyy2, mm, dd, yyyy);
* * * * ** ** *
*** ** * * * * ** ** **
**** * **** **** ** ****
* * * * ** * *** * ** ** * * ** * * **** *** **** ** *** *** *** *** ***
* * * ** *** * ***** **
** * ** * * * *** * *** * * * * 0;

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

#include <string.h>

int main(void)

{

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

    {
** * *** ** *** ***** ** **** * ** * * * *** ** * * *** * is earlier than %d/%d/%d",m2,d2,y2,m1,d1,y1);

    }
****** * * ** **** * ** if(y2>y1)

    {
*** *** ** * ** *** * *** * ** * * ****** *** is earlier than %d/%d/%d",m1,d1,y1,m2,d2,y2);

    }
**** **** * **** * ** *** **

    {
* * ** * * ** **** *** * * * ** * **** **** *
* *** * **** * * *** * *** * * * * * *** * *
***** * * * *** * * * *** ** * * * * * **** * ** ***** * * * ** * ********** ** *** * is earlier than %d/%d/%d",m2,d2,y2,m1,d1,y1);
*** * *** ** * ** ** *** ** * * * * * ** **
**** * * ** ** ** ** * *** ** **** ****** * * **** if(m2>m1)
**** * ********* * ***** ** **** * ****
* **** *** * ** **** * *** ** * *** * * * * * * ** * * *** * * * * ** * *** * * * ** is earlier than %d/%d/%d",m1,d1,y1,m2,d2,y2);
* * **** * ** * ** * * ** * ** * *** * * *
*** *** *** *** * ** * ** * * ***** **** *
*** *** * * * ** * ** * **** * *** ** ** *** *
**** * * * ** * * ** * * * ** ** * ** *** ***** * **** * * * *** *
** ** * ** * * * ** * * * ****** * * ** *** *** ** ****** ***** ** * *
***** * * * * ********* * *** ** * ***** ** * ** * * * *** * * *** * ****** * * *** ** ***** * ** * *** is earlier than %d/%d/%d",m2,d2,y2,m1,d1,y1);
* * ** * ** **** **** ** * * *** * * * ** ** *** ***** *** *
** * * * * * * ** * ** * * *** *** **** * ** * * ******** * * * *** if(d2>d1)
*** * ** *** * **** ** * * *** * ****** * ** ** * ** * ** * * * *** ** * **
* * * ** * ** * ******* ************ ** ** ** **** * ** * * * * * ** * *** * **** ** **** ** * * is earlier than %d/%d/%d",m1,d1,y1,m2,d2,y2);
* ** **** * *** ******* * * * * * *** * ** *** **** **** * ** * *
*** *** * * * * * **** ** **** * ***** *** ****** * * *
** * ** * ** **** * * ** * * * ** *** *** **** *** ** * *
* *** ** * ** * ** * ** ** ** * * ** * * * * * ** ***** ** * ** * **** ** * * ****** ** * day!");
* *** * * * * * ***** ** ** * * * ***** * ****** * **
** **** ** * *** ** **** * * * * *** *** *

    }
* * ** ** * ** 0;

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

#include<string.h>



int main()

{
**** ** * * * ** a,b,c,d,e,f,g,h;
** ** * ***** * ****** *** ** * * *** * * * **** ** * *
******* * *** ** * *** * ** *** ***** * * *** ** * * *** ** **
* * ** **** ** * * **
* ** ** ******* *** **** * * **
**** ***** * ** ** * ** ****** *
** * * * * ** ** ** *
** ** * **** ** * * * *** * * ******** * * * * * *** ** is earlier than %d/%d/%d",a,b,c,d,e,f);
** * * * * *** *** * ** *
* *** ** ** * *** *** ** * if(g>h)
* ** * * ** *
* **** * * ** ** ** *** * * ** *** **** **** * **** is earlier than %d/%d/%d",d,e,f,a,b,c);
*** * * ** ** ****
***** * * * ** ** *
***** *** * * * ******* *
**** * ** *** *** ****** *** ** ** * ******* * * ***** day!");
* * * * *** * ** * * *
** ** ** * **** * *** ** * 0;

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





int main (void)

{
* * * * * * * *** * * * * a,b,c,d,e,f;
** ***** **** * * *** **** ***** * * * **** ***** *****
*** **** *** * * ** *** * * * * * ** ***** * ** ** *** ***
* ** * * *** ** * ** *
*** * ***** * * * *
* ***** * * * * * ** ** * * * ** * * ** * **** *** is earlier than %d/%d/%d",d,e,f,a,b,c);
** ****** ** *****
* * * **** ******** * if(c<f)
***** * * * * * **
** * *** * * ** * ** * * ** * * ** * * * ** * * ** *** is earlier than %d/%d/%d",a,b,c,d,e,f);
*** *** * * *** ** ******
* * * * * ********* if(a>d)
* * *** * ** **** * ***
******** * ** ** **** ***** *** * * * * * * *** * *** * * *** is earlier than %d/%d/%d",d,e,f,a,b,c);
*** * * * *** * *
******* **** ** * ** * ** if(a<d)
* * ** * ** *
** * ** * * *** * * * * * ***** ** *** ** * * * ** * * is earlier than %d/%d/%d",a,b,c,d,e,f);
* * *** * * ** *
*** * * ** * * ** * if(b>e)
* * ******* * *** * ****
* ** * * * **** ** ** ****** * ** * * * * * is earlier than ** ****** ** * ***
** * ***** ** * * * * * *
* *** ** * * ** ** if(b<e)
* ** * * * ** **
* * * ** ** ** * *** * ****** ***** *** **** ** * ** * * * * * is earlier than %d/%d/%d",a,b,c,d,e,f);
* ** *** ****** * *
* ** * *** * ** ** * *
* *** * * ** * **** *
** * **** ** ** ** * * ** ** ******* ** * **** ** * * day!");
* * ** * * * * ***

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

#include <stdlib.h>



/* run this program using the console pauser or add your own getch, system("pause") or input loop */



int main()

{
* ** * * ***** ****** ** ***** D1,M1,Y1,D2,M2,Y2;
***** * * * **
*** ********* **** * * * ** * * * * * ********* * * ***
* ** ** * * * * * **** ** * *** * *** ** *** * *
***** **** * **** * * * *
* * ** *** * ** * * * ** (Y1<Y2)
** *** * * * * *** ** * *** * *** * * ** * * is earlier than **** *** *** * * * *
** ** * ** **** ** ** if (Y2<Y1)
** ** ** * * ** * * *** * * ** ** **** *** ******* is earlier than *** * *** *** * * * *
* ** ** * **** *** if (Y1=Y2)
** ** * * *** *** ***
* * * * * ** * ** *** * * * ** ** (M1<M2)
******** ** ** ****** ** * **** ** ** ** * * * ** *** * * ** *** * is earlier than %d/%d/%d",M1,D1,Y1,M2,D2,Y2);
* ** * *** * *** * * * *** ****** if (M2<M1)
*** *** * ** * ** ** ** * *** * **** ***** **** ** ******* ***** ** *** ** ** * *** ** is earlier than ** * **** * * * * **
** ** * * * * ******* *** ******** * ** * if (M1=M2)
** ******* ** * * * * * *** ****
* * * *** * * * * * ** * * ** **** ** ** ** * ** * * * * * *** ** * (D1<D2)
** * * * * * *** ** * *** *** ** * * **** * ** ** * * * ** ****** * * * * * **** * ** * **** * is earlier than %d/%d/%d",M1,D1,Y1,M2,D2,Y2);
* ***** * * * * * * ** * **** ** * *** * * ** * * * * * * ** * * *** if (D2<D1)
***** ** * **** * * ** *** ** * **** * ****** ** ** ** *** * * ** * * * * ** * is earlier than %d/%d/%d",M2,D2,Y2,M1,D1,Y1);
* * * * ** * * *** * * * ** ** * **** * * * * ** * if(D1=D2)
* ** ******** * * * ***** * * * * * *** *** * * * * * * * **** ** **** * * * ** * *** ** ** **** day!");
** ** * * * * * * ****** * ** * *** **
* ** * * * * *** * *
* * * ** *
* ** ** * * * ** * 0;

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

#include <stdlib.h>



/* run this program using the console pauser or add your own getch, system("pause") or input loop */



int main()

{
* *** ** ** **** ** * D1,M1,Y1,D2,M2,Y2;
* * * ** * ** ** **
** * * * ***** * ** * ** ***** ** ****** ** *** ****** ** **
** ** * * * * *** * * * ***** ***** *** ** ** * * ** *
* ** * **** ** * *
* * ** * * ****** * (Y1<Y2)
******** * ** * ** * * *** * *** * *** *** * ** *** * ** is earlier than * * ** ** ********** **
**** * ** ** ** * ** * ******** if (Y2<Y1)
** * **** * * ** ** *** * * ** *** ** * *** * ** **** * * is earlier than %d/%d/%d",M2,D2,Y2,M1,D1,Y1);
* ****** ** * * ** * ** if (Y1=Y2)
** * * **** ** * *
** **** *** ** * * * ** * ** ** * * ****** ** (M1=M2)
* *** * *** * * *** * ** * * ** * * * ** * ***
* ****** ***** * ** * ***** ** * ** ** ** *** **** * * * *** * ** * ** *
*** * ** * *** * *** * * * * ** ** ** * *** ** *** ** ** * *** ** * **** * * ** ** * * ** * * * * **** day!");
** ** * ***** *** * *** *** ** ** * ******* ** ** ** * * *** if (D1<D2)
* ** *** ** * * * * ** * ** * ** ** * ** ** ** ** *** * * * *** *** * * *** * * **** * * ** is earlier than %d/%d/%d",M1,D1,Y1,M2,D2,Y2);
*** ** **** * * * * ** * * *** *** * * * * * * ** * * * if (D2<D1)
*** * **** ** ****** ** * * * * * * ** ** * ** * * * *** ** * ** * * * *** **** ** * is earlier than %d/%d/%d",M2,D2,Y2,M1,D1,Y1);
* * * ** * *** ***** ** * * *** * ** * *
*** ** **** ** * * * ** * **** ** * *** if (M1<M2)
*** * * ** ** * * **** ** *** * * *** *** * * * * * ******* ** * ** ** ** is earlier than ** * * ** * ** ***
** * * ** * ** * * * * ** * * ** *** ** ** * if (M2<M1)
*** * ** * * * * ** ** * *** ******* *** * * ** ** * ** * * *** ** * * ***** * ** is earlier than ** ***** * ** ***
** * * * * * * ** *
* ** * * **** **** * * *
* ** * * *** * * * * 0;

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

#include <stdlib.h>



/* run this program using the console pauser or add your own getch, system("pause") or input loop */



int main()

{
*** ** ** * * *** *** D1,M1,Y1,D2,M2,Y2;
** * ***** * * * *
* *** * * * * **** * *** *** ** * * ** *** ** * ******* * * *
* * * ** *** *** ** * *** * ** ** * * * ** ** ** *** *
*** **** **** *
** ** * *** ** * **** * ** (Y1<Y2)
* * ****** *** **** * **** ** * * * * ***** * * * * * * is earlier than * ** * ** ****** ***
* ** ** * * ** * *** * if (Y2<Y1)
***** ** ** * * ********* * * * * **** ** * * ** ******** * * is earlier than %d/%d/%d",D2,M2,Y2,D1,M1,Y1);
* * * ** *** *** ** ** if (Y1=Y2)
* **** ********* * *
* * * * * * * *** * *** ** *** ***** * (M1=M2)
** * ** * * * * * *** * ** * * ** ** ** *
* * ******* * ** * ** * * * * * ** *** ** * **** * *** * ** *** *
* ** * * ** * * * * *** **** * ** *** * * *** ***** * * * ** * * *** *** ** * * * * * * * ** ** ** day!");
* *** * *** * *** ** * *** * * * *** * * * **** *** * ***** if (D1<D2)
* * * **** * ** * ** * ** * ** ** ** * * ** ******** * * * * ** * * ** **** * * ** * ** is earlier than %d/%d/%d",D1,M1,Y1,D2,M2,Y2);
** **** ** ***** ******* * ** * * ** **** **** ** * * *** * if (D2<D1)
* * ** ** * * * * *** * **** ** * * ******** ** ********** * * * ** * *** * ** * * * ** * * is earlier than %d/%d/%d",D2,M2,Y2,D1,M1,Y1);
********** ********* * **** * ** * * ** **** *
* * * ** ** * * * * * ** ****** * *** *** if (M1<M2)
***** * * * *** ** * * * ** *** * * * **** **** ** * * * *** * * is earlier than * * *** ** * **
******* ** ** ****** *** ** **** * * ** ** * * * if (M2<M1)
****** *** ** ** * * * *** * ** * * * ******* ****** * ******* * *** *** ***** ***** is earlier than ** * ** * * * * * *
* * * * * * ** *
*** ***** * * ** * **
*** * *** * * * ** * * 0;

}
answered by (-190 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 * * **** * 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 (44 points)
Welcome to Peer-Interaction Programming Learning System (PIPLS) LTLab, National DongHwa University
English 中文 Tiếng Việt
IP:172.71.1.190
©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