Calculating number of days for a given date code suggestions/how to func?
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;
(long int)t=(y-1)*365.25+month+d;
switch (m) {
case 1:month=d;
case 2:month=31+d;
case 3:month=59+d;
case 4:month=90+d;
case 5:month=120+d;
case 6:month=151+d;
case 7:month=181+d;
case 8:month=212+d;
case 9:month=243+d;
case 10:month=273+d;
case 11:month=304+d;
case 12:month=334+d;
default:break;
}printf("%li days past since jesus was born", t);
getchar();
return0;
}
I wrote this code myself and I am pretty new in C programming I just like have suggestions about what I did wrong and right and I have some questions if u can help
1.I dont know intending format checked on internet couldnt find exact answer
2.I tried changed this a function compiler said nested functions are disabled
3.I did casting for "t" but I dont know what value I will get for instance for x.75 will compiler give me x or x+1?