The Wayback Machine - https://web.archive.org/web/20241126221249/https://www.geeksforgeeks.org/c-program-find-area-circle/
Open In App

Program to find area of a circle

Last Updated : 20 Mar, 2024
Summarize
Comments
Improve
Suggest changes
Like Article
Like
Save
Share
Report
News Follow

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.
 

Area-of-circle


 

[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 result in float.
 

C++
// C++ program to find area
// of circle
#include <iostream>
const double pi = 3.14159265358979323846;
using namespace std;

// function to calculate the area of circle
float findArea(float r)
{
    return (pi * r * r);
}
// driver code
int main()
{
    float r, Area;
    r = 5;

    // function calling
    Area = findArea(r);
    // displaying the area
    cout << "Area of Circle is :" << Area;
    return 0;
}
C
// C program to find area
// of circle
#include <stdio.h>
#include <math.h>
#define PI 3.142

double findArea(int r)
{
   return PI * pow(r, 2);
}

int main()
{
    printf("Area is %f", findArea(5));
    return 0;
}
Java
// Java program to find area
// of circle
    
class Test
{
    static final double PI = Math.PI;
         
    static double findArea(int r)
    {
       return PI * Math.pow(r, 2);
    }
         
    // Driver method
    public static void main(String[] args) 
    {
        System.out.println("Area is " +  findArea(5));
    }
}
Python3
# Python3 program to find Area of a circle

def findArea(r):
    PI = 3.142
    return PI * (r*r);

# Driver method
print("Area is %.6f" % findArea(5));

# This code is contributed by Chinmoy Lenka
C#
// C# program to find area of circle
using System;

class GFG
{
    static double PI = Math.PI;
        
    static double findArea(int r)
    {
    return PI * Math.Pow(r, 2);
    }
        
    // Driver method
    static void Main() 
    {
        Console.Write("Area is " + findArea(5));
    }
}

// This code is contributed by Sam007.
PHP
<?php
// PHP program to find area
// of circle
     
function findArea( $r)
{
    $PI =3.142;
    return $PI * pow($r, 2);
}
 
// Driver Code
echo("Area is ");
echo(findArea(5));
return 0;

// This code is contributed by vt_m.
?>
JavaScript
<script>

// Javascript program to find area 
// of circle 

let pi = 3.14159265358979323846;  

// function to calculate the area of circle 
function findArea(r) 
{ 
    return (pi * r * r); 
} 

// Driver code 
    let r, Area; 
    r = 5; 

    // function calling 
    Area = findArea(r); 
    
    // displaying the area 
    document.write("Area of Circle is :" + Area); 
    
// This code is contributed by Mayank Tyagi

</script>

Output

Area of Circle is :78.5398

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



Similar Reads

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
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
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
Radius of a circle having area equal to the sum of area of the circles having given radii
Given two integers r1 and r2, representing the radius of two circles, the task is to find the radius of the circle having area equal to the sum of the area of the two circles having given radii. Examples: Input:r1 = 8r2 = 6Output:10Explanation:Area of circle with radius 8 = 201.061929 Area of a circle with radius 6 = 113.097335Area of a circle with
5 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 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
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 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
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
Sum of area of alternative concentric circle with radius 1,2,3,4..........N
Given that Concentric circle of radii 1,2,3,4..........N cm are drawn. The interior of the smallest circle is colored white and angular regions are colored alternately green and white so that no two adjacent regions are of the same color. The task is to find the total area of the green region in sq cm. Examples: Input: N=100Output: 15865.0429006284
5 min read
Area of circle inscribed within rhombus
Given a rhombus with diagonals a and b, which contains an inscribed circle. The task is to find the area of that circle in terms of a and b.Examples: Input: l = 5, b = 6Output: 11.582 Input: l = 8, b = 10Output: 30.6341 Approach: From the figure, we see, the radius of inscribed circle is also a height h=OH of the right triangle AOB. To find it, we
4 min read
Area of a circle inscribed in a regular hexagon
Given a regular Hexagon with side length a, the task is to find the area of the circle inscribed in it, given that, the circle is tangent to each of the six sides.Examples: Input: a = 4 Output: 37.68 Input: a = 10 Output: 235.5 Approach: From the figure, it is clear that, we can divide the regular hexagon into 6 identical equilateral triangles. We
4 min read
Area of a square inscribed in a circle which is inscribed in an equilateral triangle
Given here is an equilateral triangle with side length a, which inscribes a circle, which in turn inscribes a square. The task is to find the area of this square.Examples: Input: a = 6 Output: 1 Input: a = 10 Output: 0.527046 Approach: let r be the radius of circle, hence it is the inradius of equilateral triangle, so r = a /(2 * ?3) diagonal of sq
4 min read
Area of circle which is inscribed in equilateral triangle
Given here is an equilateral triangle with side length a, the task is to find the area of the circle inscribed in that equilateral triangle.Examples: Input : a = 4 Output : 4.1887902047863905 Input : a = 10 Output : 26.1799387799 Approach: Area of equilateral triangle = [Tex] [/Tex]Semi perimeter of equilateral triangle = (a + a + a) / 2Radius of i
3 min read
Area of largest Circle inscribe in N-sided Regular polygon
Given a regular polygon of N sides with side length a. The task is to find the area of the Circle which inscribed in the polygon. Note : This problem is mixed version of This and This Examples: Input: N = 6, a = 4 Output: 37.6801 Explanation: In this, the polygon have 6 faces and as we see in fig.1 we clearly see that the angle x is 30 degree so th
5 min read
Area of largest Circle that can be inscribed in a SemiCircle
Given a semicircle with radius R, the task is to find the area of the largest circle that can be inscribed in the semicircle.Examples: Input: R = 2 Output: 3.14 Input: R = 8 Output: 50.24 Approach: Let R be the radius of the semicircle For Largest circle that can be inscribed in this semicircle, the diameter of the circle must be equal to the radiu
3 min read
Area of Equilateral triangle inscribed in a Circle of radius R
Given an integer R which denotes the radius of a circle, the task is to find the area of an equilateral triangle inscribed in this circle. Examples: Input: R = 4 Output: 20.784 Explanation: Area of equilateral triangle inscribed in a circle of radius R will be 20.784, whereas side of the triangle will be 6.928 Input: R = 7 Output: 63.651 Explanatio
4 min read
Calculate area and height of an isosceles triangle whose sides are radii of a circle
Given integers R and [Tex]\alpha [/Tex]representing the radius of a circle and the angle formed at the center O by the sector AB (as shown in the figure below), the task is to find the height and area of the triangle formed by connecting the points A, B, and O if possible. Otherwise, print "Not possible". Examples: Input: R = 5, [Tex]\alpha [/Tex]=
6 min read
Calculate ratio of area of a triangle inscribed in an Ellipse and the triangle formed by corresponding points on auxiliary circle
Given two integers A and B representing the lengths of semi-major and semi-minor axes of an ellipse, the task is to calculate the ratio of any triangle inscribed in the ellipse and that of the triangle formed by the corresponding points on its auxiliary circle. Examples: Input: A = 1, B = 2Output: 2Explanation: Ratio = B / A = 2 / 1 = 2 Input: A =
4 min read
Area of decagon inscribed within the circle
Given here is a regular decagon, inscribed within a circle of radius r, the task is to find the area of the decagon.Examples: Input: r = 5Output: 160.144Input: r = 8Output: 409.969 Approach: We know, side of the decagon within the circle, a = r√(2-2cos36)(Refer here) So, area of the decagon, A = 5*a^2*(√5+2√5)/2 = 5 *(r√(2-2cos36))^2*(√5+2√5)/2=(5*
4 min read
Area of circle inscribed in a Isosceles Trapezoid
Given two bases of the isosceles trapezoid ABCD as a and b, the task is to find the area of circle inscribed in this trapezoid  Examples:   Input: a = 10, b = 30 Output: Area = 235.57Input: a = 20, b = 36 Output: Area = 565.38Derivation: Given a circle inscribed in trapezium ABCD (sides AB = n and CD = m), we need to find out the height of the trap
5 min read
Area of square Circumscribed by Circle
Given the radius(r) of circle then find the area of square which is Circumscribed by circle.Examples: Input : r = 3Output :Area of square = 18Input :r = 6Output :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 di
4 min read
Area of a Circumscribed Circle of a Square
Given the side of a square then find the area of a Circumscribed circle around it.Examples: Input : a = 6 Output : Area of a circumscribed circle is : 56.55 Input : a = 4 Output : Area of a circumscribed circle is : 25.13 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
3 min read
Calculate Volume, Curved Surface Area and Total Surface Area Of Cylinder
Given radius and height of Cylinder, calculate the volume, total surface area and curved surface area of cylinder. Volume of Cylinder: The volume of cylinder is defined as the amount of three dimensional space occupied by the cylinder or the storage capacity of a cylinder. We can calculate volume of cylinder by using formula: where ' r 'is radius o
7 min read
Check if an area P can be obtained from an area of N * M
Given integers N, M and P, the task is to check if is possible to find a rectangular area of P sq. units inside a rectangular area of N × M sq units. Examples: Input: N = 3, M = 3, P = 4Output: YESExplanation: Rectangle of 2 x 2 sq. unit area Input: N = 4, M = 4, P = 7Output: NO Approach: Follow the steps below to solve the problem Find all the fac
6 min read
Program to find Circumference of a Circle
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
3 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 Trapezoid
Definition of Trapezoid : A Trapezoid is a convex quadrilateral with at least one pair of parallel sides. The parallel sides are called the bases of the trapezoid and the other two sides which are not parallel are referred to as the legs. There can also be two pairs of bases. In the above figure CD || AB, so they form the bases and the other two si
4 min read
three90RightbarBannerImg