Here's the source code for my Pi Approximation Applicaiton. This can be pasted into an editor like TextWrangler and given the file extension .c to run it.
Note, this application is written in C, and must be run using the terminal. In order for it to run, first compile it using the command gcc -Wall -fopenmp -o pi pi.c. The number of threads used for the application can be determined with the command OMP_NUM_THREADS=X where "X" is the number of desired threads. After completing these steps, the program can be run with the command ./pi
#include <studio.h>;
#include <math.>;
int main() {
float diameter = 2;
int nRects = 2000;
float width = diameter / nRects;
float x; float height;
sum = 0; float area;
float pi;
for (x=-1; x<1; x+=width) {
height = sqrt(1-x*x);
sum += height*width
}
area = sum;
printf("Area equal %f\n", area);
pi = area*2;
printf("Pi is approximated to %f\n", pi);
return 0;
}