How to resolve the algorithm Leap year step by step in the ALGOL W programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Leap year step by step in the ALGOL W programming language
Table of Contents
Problem Statement
Determine whether a given year is a leap year in the Gregorian calendar.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Leap year step by step in the ALGOL W programming language
Source code in the algol programming language
begin
% returns true if year is a leap year, false otherwise %
% assumes year is in the Gregorian Calendar %
logical procedure isLeapYear ( integer value year ) ;
year rem 400 = 0 or ( year rem 4 = 0 and year rem 100 not = 0 );
% some test cases %
for year := 1899, 1900, 1901, 1902, 1903, 1904, 1905, 1999, 2000, 2001, 2002, 2003, 2004 do begin
write( i_w := 1, s_w := 0
, year
, " is "
, if isLeapYear( year ) then "" else "not "
, " a leap year"
)
end for_year
end.
You may also check:How to resolve the algorithm Two bullet roulette step by step in the REXX programming language
You may also check:How to resolve the algorithm Array concatenation step by step in the Haskell programming language
You may also check:How to resolve the algorithm Convex hull step by step in the Haskell programming language
You may also check:How to resolve the algorithm Search in paragraph's text step by step in the 11l programming language
You may also check:How to resolve the algorithm Minesweeper game step by step in the BASIC programming language