Jump to content

Recommended Posts

Posted

Here's a program I wrote in Structured Basic on my C64 computer:

 

100 REM COMPUTING PI USING RECTANGLES

110 REM DOTS REPRESENT INDENTATIONS

120 CALL INIT

140 CALL MAIN

160 CALL OUTPUT

180 END

200 :

220 PROC INIT

240 .....TI$="000000"

260 .....A=0:B=1

280 .....N=10

300 ENDPROC

320 :

340 PROC MAIN

360 .....DX=(B-A)/N

380 .....PRINT:PRINT"DX =";DX

400 .....X=-DX

420 .....I=-1

440 .....PRINT:PRINT" I ";" X ";" Y ";" T ":PRINT

460 .....LOOP

480 ........I=I+1

500 ........X=X+DX

520 ........Y=SQR(1-X*X)

540 ........T=T+Y

560 ........PRINT I;X;Y;T

580 .....UNTIL I=N-1

600 .....PI=DX*T*4

620 ENDPROC

640 :

660 PROC OUTPUT

680 .....PRINT:PRINT"PI =";PI

700 .....PRINT:PRINT"TIME TAKEN = ";TI$

720 ENDPROC

Posted
!

Moderator Note

Isaac, you already have a number of threads on calculating pi. From now on, could you please consolidate them to one thread instead of opening up others?

For reference:

http://www.sciencefo...__1#entry679038
http://www.sciencefo...__fromsearch__1
http://www.sciencefo...__fromsearch__1
http://www.sciencefo...__fromsearch__1
http://www.sciencefo...__fromsearch__1
http://www.sciencefo...__fromsearch__1
http://www.sciencefo...__fromsearch__1

There are far too many of these. I am merge the non-repeating threads into the last of these links so you can use the single thread for your ideas, etc., on calculating pi.

Thread closed.

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.