FastPrepFind a Circle Radius from Its Area
Problems/Find a Circle Radius from Its Area

Find a Circle Radius from Its Area

AMD logoAMD● EasyINTERNONSITE INTERVIEW
QuestionFunctionExamplesConstraints

Problem statement

Source note: The internship report asks for a C program that uses static to find a circle radius. It does not give an input quantity, formula, interface, examples or constraints. This practice explicitly chooses area as input and r = sqrt(area / PI), and authors the bounds and floating-point tolerance. The C++ references use a function-local static PI constant with the corresponding C storage-duration concept; the other supported languages use their listed constant storage. The exercise grades numeric results in five supported languages, not C syntax. The same candidate account was cross-posted; it is one application. Approximate source match: 45%.

Given the area of a circle, return its radius. For this exercise, the input is the area and the formula is radius = sqrt(area / PI), with PI = 3.141592653589793. An area of 0 has radius 0. Return a number; do not round it to a fixed number of decimal places.

Keep PI in shared constant storage and use it in the calculation. In C++, declare it as a function-local static const double. The portable references use a Java static field, Python class attribute, Go package constant or JavaScript static class field. The numeric judge checks the returned radius; it does not grade C syntax or prove a declaration's storage duration from the output.

Function

radiusFromArea(area: long) → double

Examples

Example 1

area = 4return = 1.1283791670955126

Dividing area 4 by PI gives about 1.273239544735163. Its square root is about 1.128379167095513, so that is the radius.

Example 2

area = 0return = 0.0

An area of 0 gives sqrt(0 / PI) = 0. The radius is 0.

Constraints

  • 0 <= area <= 1000000000000.
  • area is an integer. The input uses a signed 64-bit integer type; the result uses double precision.
  • Use PI = 3.141592653589793.
  • The judge accepts a result when its absolute error is at most 1e-9 * max(1, abs(expected)).

More AMD problems

  • Insert After a Linked-List NodeONSITE INTERVIEW · Seen Oct 2026
  • LRU CacheONSITE INTERVIEW · Seen Oct 2026
  • Lowest Common Ancestor of a Binary TreePHONE SCREEN · Seen Oct 2026
All AMD interview questionsSee AMD hiring insights
Saved
public double radiusFromArea(long area) {
    // Write your code here.
}
Checking account…