I have a little problem with my function, which shows the user the number of days when any month and any year is input. Here is an image of the leapyear function
if mod(year,400) == 0 result=1;elseif mod(year,100) == 0 result=0;elseif mod(year,4) == 0 result=1;else result=0; end
When the month=4 and the year=2015, the results displayed are still 31. Why is that? Am i missing something?
month=input('enter any month:\n ');year=input('enter any year:\n ');result=leap(year);if (month<1) || (month>12) fprintf('month ERROR\n');elseif month==2 && result==0; fprintf('28\n');elseif month==2 && result==1; fprintf('29\n');elseif month==1||3||5||7||8||10||12; fprintf('31\n');elseif month==4||6||9||11; fprintf('30\n');
Thanks in advance
Best Answer