| 
  • If you are citizen of an European Union member nation, you may not use this service unless you are at least 16 years old.

  • Buried in cloud files? We can help with Spring cleaning!

    Whether you use Dropbox, Drive, G-Suite, OneDrive, Gmail, Slack, Notion, or all of the above, Dokkio will organize your files for you. Try Dokkio (from the makers of PBworks) for free today.

  • Dokkio (from the makers of PBworks) was #2 on Product Hunt! Check out what people are saying by clicking here.

View
 

Basic4GL Leap Year Calculator

Page history last edited by matthew 2 years, 3 months ago

Basic4GL Leap Year Calculator

 

  1. ' Leap Year Calculator
  2.  
  3. ' Declare our leap year function
  4. declare function leapyear(year)
  5.  
  6. ' Declare any variables here
  7. dim x
  8.  
  9. ' Main loop
  10. do
  11.  
  12.     ' Clear the screen
  13.     cls
  14.  
  15.     ' Ask the User to input a year
  16.     input "Enter a Year" ; x
  17.  
  18.     ' Print the result on the screen
  19.     if leapyear(x) then
  20.         print "Leap year"
  21.     else
  22.         print "Normal year"
  23.     endif
  24.  
  25.     ' Wait 1 second
  26.     sleep(1000)
  27.  
  28. loop
  29.  
  30. ' A description of how the leap year function works
  31.  
  32. ' "Every year that is exactly divisible by four is a leap year,
  33. '  except for years that are exactly divisible by 100; the centurial
  34. '  years that are exactly divisible by 400 are still leap years."
  35. '
  36. ' For example, the year 1900 wasn't a leap year but the year 2000 was.
  37.  
  38. function leapyear(year)
  39.     return (year % 4 = 0) and (year % 100 <> 0) or (year % 400 = 0)
  40. 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

Comments (0)

You don't have permission to comment on this page.