can anyone see wot ive done wrong in this piece of code? it doesnt recognise leap years accurately.
code:
struct dat{
int day;
int month;
int year;
};
main()
{
// char looping ='y';
// while (looping == 'y'||looping == 'Y')
printf("***************************\n");
printf("*A DATE CALCULATOR PROGRAM*\n");
printf("***************************\n\n");
int days, leap;
struct dat t;
printf("Please enter a date from which you wish calculate\n");
printf("how many days to the 25/12/2002\n");
scanf("%d/%d/%d", &t.day,&t.month,&t.year);
leap = ( t.year % 4 == 0 && t.year % 100 != 0 || t.year % 400 == 0 );
if (t.day > 31 ||
t.day <= 0)
printf("ERROR, there are no months with that many days\n");
else if (t.month > 12 ||
t.month <= 0)
printf("ERROR, there are no years with that many months\n");
else if (t.month == 1||
t.month == 3||
t.month == 5||
t.month == 7||
t.month == 8||
t.month == 10||
t.month == 12 &&t.day>31)
printf("ERROR, the month you have entered doesnt have that many daysin it.\n");
else if (t.month == 4||
t.month == 6||
t.month == 9||
t.month == 11 && t.day > 30)
printf("ERROR, the month you have entered doesnt have that many days in it.\n");
else if (t.month == 2 && t.day == 29&& leap != 0)
printf("ERROR, the year you entered isnt a leapyear.\n");
else if (t.month == 2 && t.day > 29 && leap == 0)
printf("ERROR, although this is a leap year, there arnt that many days in February\n");
//else
//{
//int y,m,d,l = 0;
//if (t.year>=2002
}