We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 70ce21d commit 38c58acCopy full SHA for 38c58ac
contents/monte_carlo_integration/code/c/monte_carlo.c
@@ -24,7 +24,7 @@ void monte_carlo(int samples) {
24
double estimate = 4.0 * count / (samples * radius * radius);
25
26
printf("The estimate of pi is %f\n", estimate);
27
- printf("Which has an error of %0.2f%\n", 100 * (M_PI - estimate) / M_PI);
+ printf("Percentage error: %0.2f%\n", 100 * fabs(M_PI - estimate) / M_PI);
28
}
29
30
int main() {
0 commit comments