Code:
#include <stdio.h>
int main()
{
int d,m,y,month=0;
longint t;
printf("enter a date dd-mm-yyyy: ");
scanf("%d-%d-%d", &d, &m, &y);
if (d<=0||d>31) {
printf("wrong date format!");
}else if(m<=0||m>12){
printf("wrong date format!");
}else if(y<0){
printf("Jesus was not born on that date that's all I know");
}
if(m>2 && y%4==0 && y%100!=0 || m>2 && y%400==0)
d=d+1;
switch (m) {
case 1:month=0;
break;
case 2:month=31;
break;
case 3:month=59;
break;
case 4:month=90;
break;
case 5:month=120;
break;
case 6:month=151;
break;
case 7:month=181;
break;
case 8:month=212;
break;
case 9:month=243;
break;
case 10:month=273;
break;
case 11:month=304;
break;
case 12:month=334;
break;
default:break;}
t=((y-1)*365.25)+month+d;
printf("%li days past till %d-%d-%d, since date started ", t,d,m,y);
getchar();
return0;
}
I have tried to fix the code and came out like this, check it pls, anymore suggestions ?
thanks to everybody