The Wayback Machine - https://web.archive.org/web/20240930170829/https://www.geeksforgeeks.org/program-find-circumference-circle/
Open In App

Program to find Circumference of a Circle

Last Updated : 16 Feb, 2023
Summarize
Comments
Improve
Suggest changes
Like Article
Like
Save
Share
Report
News Follow

Given radius of a circle, write a program to find its circumference.
Examples : 
 

Input : 2
Output : Circumference = 12.566

Input : 8
Output : Circumference = 50.264

 

In a circle, points lie in the boundary of a circle are at same distance from its center. This distance is called radius. Circumference of a circle can simply be evaluated using following formula. 
 

Circumference = 2*pi*r
where r is the radius of circle 
and value of pi = 3.1415.

 

 

C++




// CPP program to find circumference of circle
#include<bits/stdc++.h>
using namespace std;
  
#define PI 3.1415
  
double circumference(double r)
{
    double cir = 2*PI*r;
    return cir;
}
  
// driver function
int main()
{
  double r = 5;
  cout << "Circumference = " 
       << circumference(r);
  return 0;
} 


Java




// Java program to find circumference of circle
import java.io.*;
  
class Geometry {
      
    // utility function
    static double circumference(double r){
  
        double PI = 3.1415;
        double cir = 2*PI*r;
        return cir;
    }
      
    // driver function
    public static void main (String[] args) {
  
        double r = 5;
        double result = Math.round(circumference(r) * 1000) / 1000.0;
        System.out.println("Circumference = "+ result);
    }
}
  
// This article is contributed by Chinmoy Lenka


Python3




# Python3 code to find 
# circumference of circle
  
PI = 3.1415
  
# utility function
def circumference(r):
    return (2 * PI * r)
  
  
# driver function
print ('%.3f' % circumference(5))
  
# This code is contributed by Saloni Gupta


C#




// C# program to find circumference of circle
using System;
  
class GFG {
      
    // utility function
    static double circumference(double r){
  
        double PI = 3.1415;
        double cir = 2*PI*r;
        return cir;
    }
      
    // driver function
    public static void Main () {
  
        double r = 5;
        double result =
              Math.Round(circumference(r)
                        * 1000) / 1000.0;
                          
        Console.WriteLine("Circumference = "
                                  + result);
    }
}
  
// 


PHP




<?php
// PHP program to find 
// circumference of circle
  
$PI= 3.1415;
  
function circumference($r)
{
    global $PI;
    $cir = 2 * $PI * $r;
    return $cir;
}
  
// Driver Code
$r = 5;
echo "Circumference = ",
circumference($r);
  
// This code is contributed aj_36
?>


Javascript




<script>
  
// Javascript program to find circumference of circle 
  
function circumference(r) 
{ 
    let cir = 2*3.1415*r; 
    return cir; 
} 
  
// driver function 
   
let r = 5; 
document.write("Circumference = "
    + circumference(r)); 
  
//This code is contributed by Manoj
  
</script>


Output : 

Circumference = 31.415

Time Complexity: O(1), since there is no loop or recursion.

Auxiliary Space: O(1), since no extra space has been taken.

This article is contributed by Saloni Gupta .

 



Previous Article
Next Article

Similar Reads

Program to calculate area of inner circle which passes through center of outer circle and touches its circumference
Given a circle C1 and it's a radius r1. And one another circle C2 whose passes through center of circle C1 and touch the circumference of circle C1. The task is to find out the area of circle C2. Examples: Input: r1 = 4Output:Area of circle c2 = 12.56Input: r1 = 7Output:Area of circle c2 = 38.465 Approach: Radius r2 of circle C2 is [Tex]\ r2 = r1/2
6 min read
Check if it is possible to reach any point on the circumference of a given circle from origin
Given a string S representing a sequence of moves(L, R, U, and D) and an integer R representing the radius of a circle whose center is the origin (0, 0), the task is to check if it is possible to reach any point on the circumference of the given circle from the origin by choosing any subsequence of moves from the string S. If it is possible to reac
10 min read
Number of quadrilateral formed with N distinct points on circumference of Circle
Given an integer N which denotes the points on the circumference of a circle, the task is to find the number of quadrilaterals formed using these points.Examples: Input: N = 5 Output: 5Input: N = 10 Output: 210 Approach: The idea is to use permutation and combination to find the number of possible quadrilaterals using the N points on the circumfere
8 min read
Program to find Perimeter / Circumference of Square and Rectangle
The circumference of a figure is the sum of all the side lengths. To calculate the circumference of square, length of one of the side is required as all sides are equal. To calculate the circumference of rectangle, length and breadth of rectangle is required. Circumference of a Square:   The circumference of a square is given by the formula:   C =
5 min read
Program for Circumference of a Parallelogram
Given the sides of Parallelogram then calculate the circumference.Examples : Input: a = 10, b = 8 Output: 36.00 Input: a = 25.12, b = 20.4 Output: 91.04 The opposite sides of a parallelogram are of equal length and parallel. The angles are pairwise equal but not necessarily 90 degree. The circumference of a Parallelogram can be computed as sum of t
3 min read
Program to calculate angle on circumference subtended by the chord when the central angle subtended by the chord is given
Given a circle having a chord and an angle subtended by chord on center of the circle. The task here is to find the measure of the angle subtended by given chord on the circumference. Examples: Input: [Tex]\( \theta \)[/Tex] = 90Output: ABC = 45.00 degreesInput: [Tex]\( \theta \)[/Tex] = 65Output: ABC = 32.50 degrees Recommended: Please try your ap
7 min read
Find area of the larger circle when radius of the smaller circle and difference in the area is given
Given two integers r and d where r is the radius of the smaller circle and d is the difference of the area of this circle with some larger radius circle. The task is to find the area of the larger circle.Examples: Input: r = 4, d = 5 Output: 55.24 Area of the smaller circle = 3.14 * 4 * 4 = 50.24 55.24 - 50.24 = 5Input: r = 12, d = 3 Output: 455.16
4 min read
Minimum Cost Path to visit all nodes situated at the Circumference of Circular Road
Given circumference of the circle and an array pos[] which marks the distance of N points on circle relative to a fixed point in the clockwise direction. We have to find a minimum distance through which we can visit all points. We can start with any point.Examples: Input: circumference = 20, pos = [3, 6, 9] Output: min path cost =6 Explanation: If
6 min read
Angle subtended by the chord to center of the circle when the angle subtended by the another equal chord of a congruent circle is given
Given are two congruent circles with two equal chords. The angle subtended to the center from the chord of one of the circles is given. The task is to find the angle subtended by the chord to the center of another circle.Examples: Input: z = 48 Output: 48 degrees Input: z = 93 Output: 93 degrees Approach: In triangle AOB and PXQ AO = PX(radii of co
3 min read
Check if a circle lies inside another circle or not
Given two circles with radii and centres given. The task is to check whether the smaller circle lies inside the bigger circle or not.  Examples:   Input: x1 = 10, y1 = 8, x2 = 1, y2 = 2, r1 = 30, r2 = 10 Output: The smaller circle lies completely inside the bigger circle without touching each other at a point of circumference. Input :x1 = 7, y1 = 8
6 min read
Equation of circle when three points on the circle are given
Given three coordinates that lie on a circle, (x1, y1), (x2, y2), and (x3, y3). The task is to find the equation of the circle and then print the centre and the radius of the circle. The equation of circle in general form is x² + y² + 2gx + 2fy + c = 0 and in radius form is (x - h)² + (y -k)² = r², where (h, k) is the centre of the circle and r is
11 min read
Program to find smallest difference of angles of two parts of a given circle
Given a division of a circle into n pieces as an array of size n. The ith element of the array denotes the angle of one piece. Our task is to make two continuous parts from these pieces so that the difference between angles of these two parts is minimum.Examples : Input : arr[] = {90, 90, 90, 90} Output : 0 In this example, we can take 1 and 2 piec
6 min read
Program to find area of a circle
Given the radius of a circle, find the area of that circle. The area of a circle can simply be evaluated using the following formula.    [Tex]Area = \pi r^2[/Tex] where r is radius of circle and it maybe in float because value of pie is 3.14    Approach: Using the given radius, find the area using the above formula: (pi * r * r) and print the resul
3 min read
JavaScript program to find area of a circle
Learn how to calculate the area of a circle using JavaScript with this easy guide. We will show you a simple JavaScript program that does the math for you. Whether you're new to coding or looking for a quick refresher, this article has got you covered. Given the radius of a circle, find the area of that circle. The area of a circle can simply be ev
2 min read
Program to print circle pattern
Given a positive integer n i.e, the radius of the circle, print a circle using stars. Examples : Input : n = 3 Output : *** * * * * * * * * * * *** Input : n = 6 Output : ***** ** ** ** ** * * * * * * * * * * * * * * ** ** ** ** ***** Below is the implementation: C/C++ Code // C++ implementation to print circle pattern #include <bits/stdc++.h
5 min read
Program to calculate area of an Circle inscribed in a Square
Given the side of a square. The task is to find the area of an inscribed circle in a square.Examples: Input : a = 8 Output : Area of an inscribed circle: 50.24 Input : a = 12.04 Output : Area of an inscribed circle: 113.795 Given a square i.e. all sides of a square are of equal length and all four angles are 90 degrees. Below diagram depicts an ins
4 min read
Find the center of the circle using endpoints of diameter
Given two endpoint of diameter of a circle (x1, y1) and (x2, y2) find out the center of a circle. Examples : Input : x1 = -9, y1 = 3, and x2 = 5, y2 = –7 Output : -2, –2 Input : x1 = 5, y1 = 3 and x2 = –10 y2 = 4 Output : –2.5, 3.5 Midpoint Formula: The midpoint of two points, (x1, y2) and (x2, y2) is : M = ((x 1 + x 2) / 2, (y 1 + y 2) / 2) The ce
4 min read
Given equation of a circle as string, find area
Given an equation of the circle X2 + Y2 = R2 whose center at origin (0, 0) and the radius is R. The task is to find area of circle. Examples : Input : X*X + Y*Y = 25Output : The area of circle centered at origin is : 78.55 Input : X*X + Y*Y = 64Output : The area of circle centered at origin is : 201.088 Approach: Given an equation X2 + Y2 = R2 and
7 min read
Find the other-end coordinates of diameter in a circle
Given Centre coordinate (c1, c2) and one coordinate (x1, y1) of the diameter of a circle, find the other end coordinate point (x2, y2) of diameter. Examples: Input : x1 = –1, y1 = 2, and c1 = 3, c2 = –6 Output : x2 = 7, y2 = -14 Input : x1 = 6.4, y1 = 3 and c1 = –10.7, c2 = 4 Output : x2 = -27.8, y2 = 5 The Midpoint Formula: The midpoint of two end
5 min read
Find the area of largest circle inscribed in ellipse
Given an ellipse, with major and minor axis length 2a & 2b respectively. The task is to find the area of the largest circle that can be inscribed in it.Examples: Input : a = 5, b = 3 Output : 28.2743 Input : a = 10, b = 8 Output : 201.062 Approach : The maximal radius of the circle inscribed in the ellipse is the minor axis of the ellipse.So, a
3 min read
Find the Diameter or Longest chord of a Circle
Given a circle with radius 'r' is given, the task is to find the diameter or longest chord of the circle.Examples: Input: r = 4 Output: 8 Input: r = 9 Output: 18 Proof that the Longest chord of a circle is its Diameter: Draw circle O and any chord AB on it.From one endpoint of the chord, say A, draw a line segment through the centre. That is, draw
4 min read
Find the radius of the circles which are lined in a row, and distance between the centers of first and last circle is given
Given here are n circles which touch each other externally, and are lined up in a row. The distance between the centers of the first and last circle is given. The circles have a radius of equal length. The task is to find the radius of each circle. Examples: Input: d = 42, n = 4 Output: The radius of each circle is 7 Input: d = 64, n = 5 Output: Th
3 min read
Find last 2 survivors in N persons standing in a circle after killing next to immediate neighbour
Given an integer N representing N persons standing in a circle, the task is to find the last 2 persons remaining when a person kills their next to the immediate neighbor in a clockwise direction. Examples: Input: N = 5 Output: 1 4 Explanation: Initially: 1 2 3 4 5 => 1 kills 3 Standing: 1 2 4 5=> 2 kills 5 Standing: 1 2 4=> 4 kills 2 Final
6 min read
Find N random points within a Circle
Given four integers N, R, X, and Y such that it represents a circle of radius R with [X, Y] as coordinates of the center. The task is to find N random points inside or on the circle. Examples: Input: R = 12, X = 3, Y = 3, N = 5 Output: (7.05, -3.36) (5.21, -7.49) (7.53, 0.19) (-2.37, 12.05) (1.45, 11.80)Input: R = 5, X = 1, Y = 1, N = 3 Output: (4.
6 min read
Find the angle between tangents drawn from a given external point to a Circle
Given a positive integer R representing the radius of the circle and the center of the circle (X1, Y1) and another point (X2, Y2) in the cartesian plane, the task is to find the angle between the pair of tangents drawn from the point (X2, Y2) to the circle. Examples: Input: R = 6, (X1, Y1) = (5, 1), (X2, Y2) = (6, 9)Output: 96.1851 Input: R = 4, (X
7 min read
Find area of the Circle when the area of inscribed Square is given
Given the area of a square inscribed in a circle as N, the task is to calculate the area of a circle in which the square is inscribed. Examples: Input: N = 4 Output: 6.283 Input: N = 10Output: 15.707 Approach: 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
4 min read
Find if an array of strings can be chained to form a circle | Set 1
Given an array of strings, find if the given strings can be chained to form a circle. A string X can be put before another string Y in circle if the last character of X is same as first character of Y.Examples: Input: arr[] = {"geek", "king"} Output: Yes, the given strings can be chained. Note that the last character of first string is same as firs
15+ min read
Find if a point lies inside a Circle
Given a circle (coordinates of centre and radius) and a point (coordinate), find if the point lies inside or on the circle, or not. Examples : Input: x = 4, y = 4 // Given Point circle_x = 1, circle_y = 1, rad = 6; // Circle Output: Inside Input: x = 3, y = 3 // Given Point circle_x = 0, circle_y = 1, rad = 2; // Circle Output: Outside We strongly
5 min read
Find minimum radius such that atleast k point lie inside the circle
Given a positive integer K, a circle center at (0, 0) and coordinates of some points. The task is to find minimum radius of the circle so that at-least k points lie inside the circle. Output the square of the minimum radius. Examples: Input : (1, 1), (-1, -1), (1, -1), k = 3Output : 2We need a circle of radius at least 2to include 3 points.Input :
12 min read
Find if an array of strings can be chained to form a circle | Set 2
Given an array of strings, find if the given strings can be chained to form a circle. A string X can be put before another string Y in a circle if the last character of X is the same as the first character of Y. Examples: Input: arr[] = {"geek", "king"} Output: Yes, the given strings can be chained. Note that the last character of first string is s
12 min read
Practice Tags :