Thursday, June 11, 2026
HomeData Modelling & AIRadius of the circle when the width and height of an arc...

Radius of the circle when the width and height of an arc is given

Given a circle in which the width and height of an arc are given. The task is to find the radius of the circle with the help of the width and height of the arc.
Examples: 
 

Input: d = 4, h = 1 
Output: The radius of the circle is 2.5

Input: d = 14, h = 8
Output: The radius of the circle is 7.0625

 

Approach 
 

  • Let the radius of the circle be r
  • Let the height and width of the arc be h & d
  • Now, the diameter DC bisects the chord AB in two halves, each having length d/2
  • Also the diameter is divided by the chord in two parts, the part inside arc h and the remaining 2r-h
  • Now from intersecting chords theorem
    h*(2r-h) = (d/2)^2 
    or, 2rh – h^2 = d^2/4 
    so, r = d^2/8h + h/2
  • So, radius of the circle 
    r = d^2/8h + h/2

C++




// C++ program to find
// radius of the circle
// when the width and height
// of an arc is given
 
#include <bits/stdc++.h>
using namespace std;
 
// Function to find the radius
void rad(double d, double h)
{
    cout << "The radius of the circle is "
        << ((d * d) / (8 * h) + h / 2)
        << endl;
}
 
// Driver code
int main()
{
    double d = 4, h = 1;
    rad(d, h);
    return 0;
}


Java




// Java program to find
// radius of the circle
// when the width and height
// of an arc is given
class GFG
{
 
// Function to find the radius
static void rad(double d, double h)
{
    System.out.println( "The radius of the circle is "
        + ((d * d) / (8 * h) + h / 2));
}
 
// Driver code
public static void main(String[] args)
{
    double d = 4, h = 1;
    rad(d, h);
}
}
 
/* This code contributed by PrinciRaj1992 */


Python3




# Python3 program to find
# radius of the circle
# when the width and height
# of an arc is given
 
# Function to find the radius
def rad(d, h):
    print("The radius of the circle is",
        ((d * d) / (8 * h) + h / 2))
 
# Driver code
d = 4; h = 1;
rad(d, h);
 
# This code is contributed by 29AjayKumar


C#




// C# program to find
// radius of the circle
// when the width and height
// of an arc is given
using System;
 
class GFG
{
 
// Function to find the radius
static void rad(double d, double h)
{
    Console.WriteLine( "The radius of the circle is "
        + ((d * d) / (8 * h) + h / 2));
}
 
// Driver code
public static void Main()
{
    double d = 4, h = 1;
    rad(d, h);
}
}
 
// This code is contributed by AnkitRai01


PHP




<?php
// PHP program to find radius of
// the circle when the width and
// height of an arc is given
 
// Function to find the radius
function rad($d, $h)
{
    echo "The radius of the circle is ",
        (($d * $d) / (8 * $h) + $h / 2), "\n";
}
 
// Driver code
$d = 4;
$h = 1;
rad($d, $h);
 
// This code is contributed by ajit
?>


Javascript




<script>
 
// Javascript program to find
// radius of the circle
// when the width and height
// of an arc is given
 
// Function to find the radius
function rad(d, h)
{
    document.write("The radius of the circle is "
    +((d * d) / (8 * h) + h / 2));
}
 
// Driver code
    var d = 4, h = 1;
    rad(d, h);
 
</script>


Output:

The radius of the circle is 2.5

Time Complexity: O(1)

Auxiliary Space: O(1)

Feeling lost in the world of random DSA topics, wasting time without progress? It’s time for a change! Join our DSA course, where we’ll guide you on an exciting journey to master DSA efficiently and on schedule.
Ready to dive in? Explore our Free Demo Content and join our DSA course, trusted by over 100,000 neveropen!

RELATED ARTICLES

3 COMMENTS

Most Popular

Dominic
32515 POSTS0 COMMENTS
Milvus
131 POSTS0 COMMENTS
Nango Kala
6896 POSTS0 COMMENTS
Nicole Veronica
12012 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12109 POSTS0 COMMENTS
Shaida Kate Naidoo
7019 POSTS0 COMMENTS
Ted Musemwa
7262 POSTS0 COMMENTS
Thapelo Manthata
6976 POSTS0 COMMENTS
Umr Jansen
6963 POSTS0 COMMENTS