|
Basic4GL Leap Year Calculator
Page history
last edited
by matthew 4 years, 7 months ago
Basic4GL Leap Year Calculator
-
' Leap Year Calculator
-
-
' Declare our leap year function
-
declare function leapyear(year)
-
-
' Declare any variables here
-
dim x
-
-
' Main loop
-
do
-
-
' Clear the screen
-
cls
-
-
' Ask the User to input a year
-
input "Enter a Year" ; x
-
-
' Print the result on the screen
-
if leapyear(x) then
-
print "Leap year"
-
else
-
print "Normal year"
-
endif
-
-
' Wait 1 second
-
sleep(1000)
-
-
loop
-
-
' A description of how the leap year function works
-
-
' "Every year that is exactly divisible by four is a leap year,
-
' except for years that are exactly divisible by 100; the centurial
-
' years that are exactly divisible by 400 are still leap years."
-
'
-
' For example, the year 1900 wasn't a leap year but the year 2000 was.
-
-
function leapyear(year)
-
return (year % 4 = 0) and (year % 100 <> 0) or (year % 400 = 0)
-
endfunction
- The inspiration for this program came from this topic on the Basic4GL Forum
- More can be found out about Leap years on this Wikipedia page
- Code Syntax Highlighting by Quick Highlighter
Basic4GL Leap Year Calculator
|
Tip: To turn text into a link, highlight the text, then click on a page or file from the list above.
|
|
|
Comments (0)
You don't have permission to comment on this page.