The programme is from the magazine Sinclair Programs, August 1985 issue, and was written for the Spectrum or Spectrum Plus computers of the day.
Since DB Classic does not recognise line numbers, I had to show them as labels (the number followed by a colon). Not that they are necessary in the running of the programme. Just for reference.
As you can see, the programme contains a few of the so-called dreaded goto's, between lines 150 and 280, and I'd like to issue a challenge as to how this part of the programme could be written differently.
do
10:
dim m(25,25)
20:
print "Enter size of square (must be odd number 3,5,7 or 9)"
30:
input n
40:
print "Enter starting number (from 1 to 19)"
50:
input y
60:
s=y
70:
print n;" by ";n;" Magic Square starting"
80:
print " with the number ";s
90:
print
100:
k=1
110:
h=1
120:
j=(n+1)/2
130:
m(h,j)=s
140:
s=s+1
150:
if s>n^2+y-1 then goto 290
160:
if k<n then goto 200
170:
k=1
180:
h=h+1
190:
goto 130
200:
h=h-1
210:
j=j+1
220:
k=k+1
230:
if h<>0 then goto 260
240:
h=n
250:
goto 130
260:
if j<=n then goto 130
270:
j=1
280:
goto 130
290:
for i=1 to n
300:
for j=1 to n
310:
print m(i,j);" ";
320:
next j
330:
print
340:
print
350:
next i
360:
print
370:
print "The constant is ";(n^3+n)/2+n*(y-1)
print
print "Press any key to re-run"
wait key
cls
loop
gearce
(GRC)
LANG MEY YER LUM REEK
That's ODD ...... In 1911, 3 men were hung for the murder of Sir Edmund Berry at Greenbury Hill, their last names were Green, Berry, and Hill.