Magic Square

Date: 198x
Type: Program
Platform(s): TS 2068

Appears on

Library tape of the Indiana Sinclair Timex User’s Group.

Source Code

  190 CLS 
  200 INPUT "Type a beginning number for       your magic square ";a$
  210 IF a$<"1" OR a$>"999" THEN GO TO 200
  300 INPUT "Type a difference between each       number on your square ";b$
  310 IF b$<"1" THEN GO TO 300
  320 CLS 
  400 DIM a(9): LET a(1)=VAL a$: LET y=1: LET z=VAL b$
  410 FOR x=2 TO 9: LET a(x)=a(1)+y*z: LET y=y+1: NEXT x
  420 PRINT AT 5,3;a(8);AT 5,8;a(1);AT 5,13;a(6)
  430 PRINT AT 7,3;a(3);AT 7,8;a(5);AT 7,13;a(7)
  440 PRINT AT 9,3;a(4);AT 9,8;a(9);AT 9,13;a(2)
  450 PRINT '''"  The sum of each row, column,  and diagonal of the magic       square is...........";a(8)+a(1)+a(6)
 1190 STOP 
 1200 INPUT "Type a beginning number for       your magic square ";a$
 1210 IF a$<"1" OR a$>"999" THEN GO TO 200
 1300 INPUT "Type a difference between each       number on your square ";b$
 1310 IF b$<"1" THEN GO TO 300
 1320 CLS 
 1400 DIM a(9): LET a(1)=VAL a$: LET y=1: LET z=VAL b$
 1410 FOR x=2 TO 9: LET a(x)=a(1)+y*z: LET y=y+1: NEXT x
 1420 LPRINT : LPRINT a(8);TAB 5;a(1);TAB 10;a(6)
 1430 LPRINT : LPRINT a(3);TAB 5;a(5);TAB 10;a(7);TAB 20;"Sum= ";a(8)+a(1)+a(6)
 1440 LPRINT : LPRINT a(4);TAB 5;a(9);TAB 10;a(2)
 1450 LPRINT : GO TO 1200
 9990 SAVE "magic" LINE 1: BEEP .4,15

People

No people associated with this content.

Scroll to Top