Quarter squares table

Highlight the following code and save it as a text file called QTR_SQRS.BAS
Put it in the same folder as GW-BASIC.EXE. Load it and run it.

10 REM Table of Quarter Squares
20 CLEAR :CLS :KEY OFF
30 PRINT,,"QUARTER SQUARES" :PRINT
40 PRINT "Before the discovery of logarithms, tables of quartersquares were used"
50 PRINT "for multiplication. The quartersquare of an integer is the integer part"
60 PRINT "of one quarter of its square." :PRINT
70 PRINT "To multiply the two numbers x and y it is simply necessary to calculate"
80 PRINT,"xy = quartersquare(x+y) - quartersquare(x-y)" :PRINT
90 PRINT "Press any key for a sample table of quartersquares of integers up to 199."
100 GOSUB 260                         'PRESS ANY KEY
110 PRINT TAB(13);
120 FOR UNIT = 0 TO 9
130    PRINT USING "######";UNIT;
140 NEXT UNIT
150 PRINT :PRINT
160 FOR TENS = 0 TO 190 STEP 10
170    PRINT TAB(8); USING "####";TENS;
180    PRINT " ";
190    FOR NUMBER = TENS TO TENS+9
200       PRINT USING "######"; INT(NUMBER^2/4);
210    NEXT NUMBER
220    PRINT
230 NEXT TENS
240 END
250 ' ----------------------------------------------
260 '                                  PRESS ANY KEY
270 ' ----------------------------------------------
280 LOCATE 25,1 :PRINT ,,,"Press any key to continue";
290 WHILE INKEY$ = "" :WEND
300 CLS
310 RETURN

Previous | Home | Next