I have to wirte a code for monte carlo pi approximation for a menu driven calculator. here is my code but when i run it it shows me 1 instead of the pi value. can someone tel me what is wrong.

```
double approximatepi(void)
{
double x,y,z,pi,randomnumber;
double r,p,in;
int tries;
srand(0);
while (tries!=p)
{randomnumber=((double)rand())/((double)RAND_MAX)*2*r;
x=randomnumber;
y=randomnumber;
z=r*r;
pi=(((double)in/(double)p))*4;
if (z>=x*x+y*y)
{in++;
}
}
return pi;
}
```