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;
while (tries!=p)
 if (z>=x*x+y*y)

return pi;

Recommended Answers

All 2 Replies

variables r, p and tries are used but never assigned a value

And your formatting makes the code very difficult to follow. Try a better fomrat and we can be much more helpful.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.