Day of the week: Difference between revisions
Content added Content deleted
(Dialects of BASIC moved to the BASIC section.) |
(→{{header|GW-BASIC}}: Used features of GW-BASIC to simplify expressions. Added output.) |
||
Line 822: | Line 822: | ||
==={{header|GW-BASIC}}=== |
==={{header|GW-BASIC}}=== |
||
<syntaxhighlight lang="gwbasic">10 |
<syntaxhighlight lang="gwbasic">10 REM Day of the week |
||
20 D |
20 DEFINT D, M, Y-Z |
||
30 |
30 M = 12: D = 25 |
||
40 FOR Y = 2007 TO 2122 |
|||
50 GOSUB 200 |
|||
60 IF Z = 0 THEN PRINT Y; |
|||
60 NEXT Y |
|||
70 |
70 NEXT Y |
||
80 PRINT |
|||
100 REM CALCULATE DAY OF WEEK Z GIVEN |
|||
90 END |
|||
110 REM YEAR Y, MONTH M AND DAY D |
|||
170 REM Calculate day of week Z given |
|||
180 REM year Y, month M, and day D |
|||
190 REM Sunday = 0, Saturday = 6 |
|||
⚫ | |||
200 IF M < 3 THEN Y = Y - 1: M = M + 12 |
|||
⚫ | |||
⚫ | |||
220 Z = Z + D + (153 * M + 8) \ 5 |
|||
⚫ | |||
⚫ | |||
⚫ | |||
{{out}} |
|||
<pre> |
|||
2011 2016 2022 2033 2039 2044 2050 2061 2067 2072 2078 2089 2095 2101 2107 2112 2118 |
|||
</pre> |
|||
==={{header|IS-BASIC}}=== |
==={{header|IS-BASIC}}=== |