Commit 41155144 by chazog

Upload New File

parent 7d2aa165
Showing with 34 additions and 0 deletions
#include <stdio.h>
int main () {
int num, dd, mm, yy;
printf("Please enter the date ddmmyy:\n");
scanf("%d", &num);
dd = num / 1000000;
mm = (num % 1000000)/10000;
yy = (num % 10000);
printf ("%d,%d,%d\n", dd,mm,yy);
int bissextile = yy % 400 == 0 || (yy % 4 == 0 && yy % 100 != 0);
if (dd>31 || dd<1 || mm>12 || mm<1)
printf("Invalid date.\n");
if((mm==2 && dd<30 && bissextile) || (mm==2 && dd<29 && bissextile==0))
printf("valid date.\n");
else
if((mm==4 || mm==6 || mm==9 || mm==11)&& dd<31)
printf("valid date.\n");
else
if(dd<31 && mm!=2)
printf("valid date.\n");
else
printf("Invalid date.\n");
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment