Array of the number of days in the month of February this year
5 次查看(过去 30 天)
显示 更早的评论
The number of days in the month of February this year
1 个评论
回答(2 个)
RANGA BHARATH
2023-6-12
Question: How many days are there in the February month this year?
Solution:
A year is a leap year if the following conditions are satisfied:
- The year is multiple of 400.
- The year is multiple of 4 and not multiple of 100.
Code:
year = int64(input("Enter the year: "));
num_days_in_feb = 28;
%% mod(a,b) returns the remainder when a is divided by b
if(mod(year,400)==0)
num_days_in_feb = 29;
elseif(mod(year,100)~=0 && mod(year,4)==0)
num_days_in_feb = 29;
end
fprintf("Number of days in February in the year %d = %d",year,num_days_in_feb);
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Calendar 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!