clc,clearall,closeall disp('This program calculates the day ofyear given the'); disp('current date.');
month=input('Enter current
month(1-12):
');
day=input('Enter current day(1-31):
');year=input('Enter current year(yy):
');%Check for leap year,and add extra day ifnecessary ifmod(year,400)==0
leap_day=1;%Years divisible by 400 areleap years elseifmod(year,100)==0
leap_day=0;%Other centuries are not leapyears elseifmod(year,4)==0
leap_day=1;%Otherwiseevery4thyearisaleap year
else
leap_day=0;%Otheryearsarenotleapyearsend
%Calculate day of year by adding currentday to the
%days in previous months.
day_of_year=day;
forii=1:month-1
1/ 2