This code shows a function intended to determine if a year is between a range, and if it belongs to a leap year (Bisiesto in spanish: those years with 366 days, each 4 years in the graegorian calendar)
int bisiesto(int anyo)
{
printf("%d\n",anyo);
if(anyo >= 1601 && anyo <= 3000)
{
if((anyo%4 == 0 && anyo%100 !=0) || anyo%400 ==0)
{
return(1);
}
else
{
return(0);
}
}
else
{
return(0);
}
}
And this function is called from the main() function with:
if (bisiesto(anyo) == 1)
{
printf("Es bisiesto");
}
else
{
printf("No es bisiesto");
}
Well, the problem is that even the conditions are defined in the bisiesto()
function, the program always tell us if we have a 'bisiesto' year or not. Why it passes over the IF in the bisiesto function?