How to Calculate Pi Using GNU Cobol Program

by richrobi in Design > Software

146 Views, 1 Favorites, 0 Comments

How to Calculate Pi Using GNU Cobol Program

Pi-2.jpg

This project calculates Pi.

The logic is Circle area = Pi * R **2 so = Pi * 4 when R=2, so Pi is equal to a quarter of the circle area.

This project is to write a program to determine the area of a quarter of a circle with Radius of 2.

The program is written in GNU Cobol

Supplies

GNU-Cobol.jpg

GNU Cobol program runs on Linux or Windows operated PC.

Compile and Run the Program

Install GNU Cobol on a PC. For this project the PC runs GNU Cobol on Mint Linux. The design is to start with a 2x 2 triangle and get its area, then 1/2 its hypotenuse make two new triangles ad their area to the final answer then 1/2 their hypotenuse and new triangles etc etc until adding new triangles does not improve accuracy. As shown in the output, it takes 67+ million triangles to get the final answer (accurate to 15 decimal points).

NOTE: The Source is attached as a .txt and should be changed to .cob for compiling. Once the program is run it produces a report (also attached) showing the output for each step increasing the number of triangles to the accuracy limit of the PC. I have tried to attach the compiled binary but your system will not allow it.

The author gives everyone full rights to copy modify and use the source for whatever reason they wish.