Program to find area of a circle Last Updated : 27 Dec, 2024 Comments Improve Suggest changes Like Article Like Report Try it on GfG Practice Given the radius r. Find the area of a circle. The area of the circle should be correct up to 5 decimal places. Examples:Input: r = 5Output: 78.53982Explanation: As area = PI * r * r = 3.14159265358979323846 * 5 * 5 = 78.53982, as we only keep 5 digits after decimal.Input: r = 2Output: 12.56637Explanation: As area = PI * r * r = 3.14159265358979323846 * 2 * 2 = 12.56637, as we only keep 5 digits after decimal.The area of a circle can be calculated using the formula: area = PI * r * r C++ #include <iostream> #include <cmath> #include <iomanip> using namespace std; float findArea(float r) { return (M_PI * r * r); } int main() { float r = 5, area; area = findArea(r); cout << fixed << setprecision(5) << area; return 0; } C #include <stdio.h> #include <math.h> #define PI 3.14159265358979323846 float findArea(float r) { return (PI * r * r); } int main() { float r = 5, area; area = findArea(r); printf("%.5f\n", area); return 0; } Java import java.lang.Math; class GfG { static float findArea(float r) { return (float)(Math.PI * r * r); } public static void main(String[] args) { float r = 5; float area = findArea(r); System.out.printf("%.5f%n",area); } } Python import math def findArea(r): return math.pi * r * r if __name__ == "__main__": r = 5 area = findArea(r) print(f"{area:.5f}") C# using System; class GfG { static float FindArea(float r) { return (float)(Math.PI * r * r); } static void Main() { float r = 5; float area = FindArea(r); Console.WriteLine("{0:F5}",area); } } JavaScript function findArea(r) { return Math.PI * r * r; } //Driver Code let r = 5; let area = findArea(r); console.log(area.toFixed(5)); Output78.53982Time Complexity: O(1)Auxiliary Space: O(1), since no extra space has been taken. Comment More infoAdvertise with us Next Article Program to find area of a Circular Segment K kartik Follow Improve Article Tags : Mathematical Geometric DSA Basic Coding Problems area-volume-programs +1 More Practice Tags : GeometricMathematical Similar Reads Program to find area of a Circular Segment In a circle, if a chord is drawn then that chord divides the whole circle into two parts. These two parts of the circle are called segments of the circle. The smaller area is known as the Minor segment and the larger area is called as the Major segment.In the figure below, the chord AB divides the c 6 min read Program to find the Area of an Ellipse Given an ellipse with a semi-major axis of length a and semi-minor axis of length b. The task is to find the area of an ellipse.In mathematics, an ellipse is a curve in a plane surrounding by two focal points such that the sum of the distances to the two focal points is constant for every point on t 4 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 o 3 min read Program to calculate area of Enneagon Enneagon is a polygon with 9 sides and 9 internal angles. Enneagon is also known as Nonagon. A regular nonagon has an internal angle of 140 degrees each. Sum of interior angles of the nonagon is 1260 degree. The center of the circumcircle is also taken as the center of the regular Nonagon. The line 3 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 heig 4 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 a 4 min read Like