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 M = 12
<syntaxhighlight lang="gwbasic">10 REM Day of the week
20 D = 25
20 DEFINT D, M, Y-Z
30 FOR Y = 2007 TO 2122
30 M = 12: D = 25
40 FOR Y = 2007 TO 2122
40 GOSUB 100
50 GOSUB 200
50 IF Z = 0 THEN PRINT Y
60 IF Z = 0 THEN PRINT Y;
60 NEXT Y
70 END
70 NEXT Y
80 PRINT
100 REM CALCULATE DAY OF WEEK Z GIVEN
90 END
110 REM YEAR Y, MONTH M AND DAY D
120 REM SUNDAY = 0, SATURDAY = 6
170 REM Calculate day of week Z given
130 IF M < 3 THEN Y = Y - 1 : M = M + 12
180 REM year Y, month M, and day D
190 REM Sunday = 0, Saturday = 6
140 Z = Y + INT(Y/4) - INT(Y/100) + INT(Y/400)
150 Z = Z + D + INT((153*M + 8)/5)
200 IF M < 3 THEN Y = Y - 1: M = M + 12
210 Z = Y + Y \ 4 - Y \ 100 + Y \ 400
160 Z = Z MOD 7
220 Z = Z + D + (153 * M + 8) \ 5
170 RETURN</syntaxhighlight>
230 Z = Z MOD 7
240 RETURN</syntaxhighlight>
{{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}}===