Area of square Circumscribed by Circle - GeeksforGeeks

07 Nov, 2021
Given the radius(r) of circle then find the area of square which is Circumscribed by circle.Examples:  
Input : r = 3
Output :Area of square = 18

Input :r = 6
Output :Area of square = 72
 
All four sides of a square are of equal length and all four angles are 90 degree. The circle is circumscribed on a given square shown by a shaded region in the below diagram.  
Properties of Circumscribed circle are as follows:  
The center of the circumcircle is the point where the two diagonals of a square meet.
Circumscribed circle of a square is made through the four vertices of a square.
The radius of a circumcircle of a square is equal to the radius of a square.
 
Formula used to calculate the area of circumscribed square is: 2 * r2 where, r is the radius of the circle in which a square is circumscribed by circle.How does this formula work?Assume diagonal of square is d and length of side is a.We know from the Pythagoras Theorem, the diagonal of a square is √(2) times the length of a side. i.e d2 = a2 + a2 d = 2 * a2 d = √(2) * a Now, a = d / √2and We know diagonal of square that are Circumscribed by Circle is equal to Diameter of circle. so Area of square = a * a = d / √(2) * d / √(2) = d2/ 2 = ( 2 * r )2/ 2 ( We know d = 2 * r ) = 2 * r2
 
CPP
Java
Python3
C#
PHP
Javascript
// C++ program to find Area of// square Circumscribed by Circle#include <iostream>using namespace std;  // Function to find area of squareint find_Area(int r){    return (2 * r * r);}  // Driver codeint main() {    // Radius of a circle    int r = 3;          // Call Function to find     // an area of square    cout << " Area of square = "                  << find_Area(r);          return 0;}
// Java program to find Area of// square Circumscribed by Circleclass GFG {          // Function to find area of square    static int find_Area(int r)    {        return (2 * r * r);    }          // Driver code    public static void main(String[] args)    {        // Radius of a circle        int r = 3;          // Call Function to find        // an area of square        System.out.print(" Area of square = "                             + find_Area(r));    }}  // This code is contributed by Anant Agarwal.
# Python program to# find Area of# square Circumscribed# by Circle  # Function to find# area of squaredef find_Area(r):      return (2 * r * r)      # driver code# Radius of a circler = 3      # Call Function to find # an area of squareprint(" Area of square = ", find_Area(r))  # This code is contributed# by Anant Agarwal.
// C# program to find Area of// square Circumscribed by Circleusing System;  class GFG {          // Function to find area of square    static int find_Area(int r)    {        return (2 * r * r);    }          // Driver code    public static void Main()    {        // Radius of a circle        int r = 3;          // Call Function to find        // an area of square        Console.WriteLine(" Area of square = "                            + find_Area(r));    }}  // This code is contributed by vt_m.
<?php// PHP program to find Area of// square Circumscribed by Circle  // Function to find area of squarefunction find_Area( $r){    return (2 * $r * $r);}      // Driver code    // Radius of a circle    $r = 3;          // Call Function to find     // an area of square    echo ("Area of square = ");    echo(find_Area($r));      // This code is contributed by vt_m.?>
<script>// Javascript program to find Area of // square Circumscribed by Circle   // Function to find area of square function find_Area(r) {     return (2 * r * r); }   // Driver code        // Radius of a circle     let r = 3;           // Call Function to find     // an area of square     document.write(" Area of square = "                + find_Area(r));       // This code is contributed by Mayank Tyagi</script>
Output: 
Area of square = 18
Time Complexity: O(1) 
vt_m
mayanktyagi1709
area-volume-programs
circle
Geometric
School Programming
Geometric
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Circle and Lattice Points
Queries on count of points lie inside a circle
Convex Hull | Set 2 (Graham Scan)
Given n line segments, find if any two segments intersect
Check if a point lies inside a rectangle | Set-2
Python Dictionary
Arrays in C/C++
Reverse a string in Java
Inheritance in C++
C++ Classes and Objects