Area of the circle that has a square and a circle inscribed in it
Given the side of a square a which is kept inside a circle. It keeps expanding until all four of its vertices touch the circumference of the circle. Another smaller circle is kept inside the square now and it keeps expanding until its circumference touches all the four sides of the square. The outer and the inner circle form a ring. Find the area of this shaded part as shown in the image below.
Input: a = 3
Input: a = 4
From the above figure, R = a / sqrt(2) can be derived where a is the side length of the square. The area of the outer circle is (pi * R * R).
Let s1 be the area of the outer circle (pi * R * R) and s2 be the area of the inner circle (pi * r * r). Then the area of the ring is s1 – s2.
Below is the implementation of the above approach:
Attention reader! Don’t stop learning now. Participate in the Scholorship Test for First-Step-to-DSA Course for Class 9 to 12 students.