- area-volume-programs, Geometric, Mathematical

Find area of the Circle when the area of inscribed Square is given

Given area of square inscribed in a circle as N, the task is to calculate the area of circle in which the square is inscribed.Examples: Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.  To complete your preparation from learning a language to DS Algo and many more,  please refer Complete Interview Preparation Course.In case you wish to attend live classes with experts, please refer DSA Live Classes for Working Professionals and Competitive Programming Live for Students.Input: N = 4 Output: 6.283Input: N = 10Output:  15.707Approach:Consider the below image:  Let the area of the square is ‘A’The side of the square is given by = A**(1/2)A right-angled triangle is formed by the two sides of the square and the diameter of the circleThe hypotenuse of triangle will be diameter of circleThe diameter of circle ‘D’ is calculated as ((A * A) + (A * A))**(1/2)The radius of circle ‘r’ is given by D/2The resultant area of the circle is pi*r*rBelow is the implementation of the above approach: Python3import math  def areaOfCircle(a):          side = a**(1 / 2)          D = ((side * side) + (side * side))**(1 / 2)          R = D / 2          Area = math.pi * (R * R)      return Area  areaOfSquare = 4print(areaOfCircle(areaOfSquare))Output6.283185307179588Time Complexity: O(1)Auxiliary Space: O(1)