How to resolve the algorithm Leap year step by step in the Component Pascal programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Leap year step by step in the Component Pascal 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 Component Pascal programming language

Source code in the component programming language

MODULE LeapYear;
IMPORT StdLog, Strings, Args;

PROCEDURE IsLeapYear(year: INTEGER): BOOLEAN;
BEGIN
	IF year MOD 4 # 0 THEN 
    	RETURN FALSE
	ELSE 
		IF year MOD 100 = 0 THEN
			IF year MOD 400  = 0 THEN RETURN TRUE ELSE RETURN FALSE END
		ELSE
			RETURN TRUE
		END
	END
END IsLeapYear;

PROCEDURE Do*;
VAR
	p: Args.Params;
	year,done,i: INTEGER;
BEGIN
	Args.Get(p);
	FOR i := 0 TO p.argc - 1 DO
		Strings.StringToInt(p.args[i],year,done);
		StdLog.Int(year);StdLog.String(":>");StdLog.Bool(IsLeapYear(year));StdLog.Ln
	END;
	
END Do;
END LeapYear.

  

You may also check:How to resolve the algorithm Optional parameters step by step in the Arturo programming language
You may also check:How to resolve the algorithm CSV data manipulation step by step in the Go programming language
You may also check:How to resolve the algorithm Square but not cube step by step in the Factor programming language
You may also check:How to resolve the algorithm First power of 2 that has leading decimal digits of 12 step by step in the Rust programming language
You may also check:How to resolve the algorithm Numeric error propagation step by step in the Common Lisp programming language