# Thread: program makes no sense to me

1. ## program makes no sense to me

Ok, I was searching for a program that can computer pi, well hey brain-**** can do it, C should be able to do it also!
I found this POS
Code:
```#include <stdio.h>
int a=10000,b,c=2800,d,e,f[2801],g;

int main(){
for(;b-c;)
f[b++]=a/5;
for( ; d=0, g=c*2; c-=14 ,printf("%.4d",e+d/a) ,e=d%a)
for(b=c;d+=f[b]*a,f[b]=d%--g,d/=g--,--b;d*=b);
return 0;
}```
I made some modifications such as #include <stdio.h>!
but the for loops make no sense!
for(; <--- WHERE IS THE FIRST VALUE!?
anyway, if someone could explain what is going on in this program it would be nice. But if you can help me find a better program for calculating pi, that would be better.
oh, and without the use of math.h's global PI
thank you.

--------
3.14159265358979323...

2. The parameters of a for loop are optinal.

for(a;b;c)

a == initialization
b == truth check
c == incrementation

Examples:

for( ; x < 20; )
{
... do something...
}

Here, we must have initialized 'x' before we use it in our loop.
Additionally, our loop must have some way to make the "x<20" check fail.
Finally, it must have some incrementation, or method of changint "x"; as per the previous sentence.

for( x = 10; ; x++ )
{
}

Here, we initialze x and we increment x, but we have no check for breaking from the loop. We must assume that some place in the code of the loop then, it has a way to break out.

Quzah.

3. thanks, after staring at that program till my head hurt I began to slowly understand it but it still is CRAP to me, but it works!

4. oh, anyway, if you just want to make a variable hold the value of pi, you can simply do this:

//make sure to include <math.h> or some other math library that supports trig functions

long double /*float*/ pi = 4*atan(1); //4 times the arc tangent of 1

or

long double pi = 2*asin(1); //2 times the arc sine of 1

or

long double pi = acos(-1); //arc cosine of -1

// don't forget that pi is 180 degrees

here is just a sample list of the first few values of pi.