I would like to understand why this code:
double r,d,rc;
scanf("%lf %lf", &r, &d);
rc = (r * r) - (d/2) * (d/2);
printf("%.2f\n", M_PI * rc);
returns more precise result than this one (without rc
variable assignment):
double r,d,rc;
scanf("%lf %lf", &r, &d);
printf("%.2f\n", M_PI * (r * r) - (d/2) * (d/2));
Another, related, question: why is n * n
better than pow(n,2)
?